Change user status from 0 to 1 after 6 months












0















I am trying to change the user status from 0 to 1 after 6 months. I have two date columns in my abc table i.e. reg_date and exp_date in which reg_date contains the date&time of registration and exp_date contains the date&time of expiry which is 6 months after of registration. I just want to change user status from 0 to 1 automatically when the current date matches with exp_date.



Here is my query :-



$reg_date=date("Y-m-d H:i:s", time()); 
$exp_date=date("Y-m-d H:i:s", strtotime('+6 month'));


Is this possible with any conditions, if possible please help me out.










share|improve this question

























  • You could create and event which would run daily to do this. But status seems like a redundant field , you know when it's expired.

    – P.Salmon
    Dec 29 '18 at 8:56











  • is your table values from database?

    – comphonia
    Dec 29 '18 at 8:57











  • Why do you want to change it in the database rather then compute it in the code by means of a function based on the date of registration?

    – jotaen
    Dec 29 '18 at 9:28











  • yes, @comphonia

    – Bhawesh
    Dec 29 '18 at 9:36











  • i am not getting you, can you explain more @jotaen

    – Bhawesh
    Dec 29 '18 at 9:38


















0















I am trying to change the user status from 0 to 1 after 6 months. I have two date columns in my abc table i.e. reg_date and exp_date in which reg_date contains the date&time of registration and exp_date contains the date&time of expiry which is 6 months after of registration. I just want to change user status from 0 to 1 automatically when the current date matches with exp_date.



Here is my query :-



$reg_date=date("Y-m-d H:i:s", time()); 
$exp_date=date("Y-m-d H:i:s", strtotime('+6 month'));


Is this possible with any conditions, if possible please help me out.










share|improve this question

























  • You could create and event which would run daily to do this. But status seems like a redundant field , you know when it's expired.

    – P.Salmon
    Dec 29 '18 at 8:56











  • is your table values from database?

    – comphonia
    Dec 29 '18 at 8:57











  • Why do you want to change it in the database rather then compute it in the code by means of a function based on the date of registration?

    – jotaen
    Dec 29 '18 at 9:28











  • yes, @comphonia

    – Bhawesh
    Dec 29 '18 at 9:36











  • i am not getting you, can you explain more @jotaen

    – Bhawesh
    Dec 29 '18 at 9:38
















0












0








0








I am trying to change the user status from 0 to 1 after 6 months. I have two date columns in my abc table i.e. reg_date and exp_date in which reg_date contains the date&time of registration and exp_date contains the date&time of expiry which is 6 months after of registration. I just want to change user status from 0 to 1 automatically when the current date matches with exp_date.



Here is my query :-



$reg_date=date("Y-m-d H:i:s", time()); 
$exp_date=date("Y-m-d H:i:s", strtotime('+6 month'));


Is this possible with any conditions, if possible please help me out.










share|improve this question
















I am trying to change the user status from 0 to 1 after 6 months. I have two date columns in my abc table i.e. reg_date and exp_date in which reg_date contains the date&time of registration and exp_date contains the date&time of expiry which is 6 months after of registration. I just want to change user status from 0 to 1 automatically when the current date matches with exp_date.



Here is my query :-



$reg_date=date("Y-m-d H:i:s", time()); 
$exp_date=date("Y-m-d H:i:s", strtotime('+6 month'));


Is this possible with any conditions, if possible please help me out.







php mysql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 29 '18 at 8:56









u_mulder

35.3k52946




35.3k52946










asked Dec 29 '18 at 8:50









BhaweshBhawesh

196




196













  • You could create and event which would run daily to do this. But status seems like a redundant field , you know when it's expired.

    – P.Salmon
    Dec 29 '18 at 8:56











  • is your table values from database?

    – comphonia
    Dec 29 '18 at 8:57











  • Why do you want to change it in the database rather then compute it in the code by means of a function based on the date of registration?

    – jotaen
    Dec 29 '18 at 9:28











  • yes, @comphonia

    – Bhawesh
    Dec 29 '18 at 9:36











  • i am not getting you, can you explain more @jotaen

    – Bhawesh
    Dec 29 '18 at 9:38





















  • You could create and event which would run daily to do this. But status seems like a redundant field , you know when it's expired.

    – P.Salmon
    Dec 29 '18 at 8:56











  • is your table values from database?

    – comphonia
    Dec 29 '18 at 8:57











  • Why do you want to change it in the database rather then compute it in the code by means of a function based on the date of registration?

    – jotaen
    Dec 29 '18 at 9:28











  • yes, @comphonia

    – Bhawesh
    Dec 29 '18 at 9:36











  • i am not getting you, can you explain more @jotaen

    – Bhawesh
    Dec 29 '18 at 9:38



















You could create and event which would run daily to do this. But status seems like a redundant field , you know when it's expired.

– P.Salmon
Dec 29 '18 at 8:56





You could create and event which would run daily to do this. But status seems like a redundant field , you know when it's expired.

– P.Salmon
Dec 29 '18 at 8:56













is your table values from database?

– comphonia
Dec 29 '18 at 8:57





is your table values from database?

– comphonia
Dec 29 '18 at 8:57













Why do you want to change it in the database rather then compute it in the code by means of a function based on the date of registration?

– jotaen
Dec 29 '18 at 9:28





Why do you want to change it in the database rather then compute it in the code by means of a function based on the date of registration?

– jotaen
Dec 29 '18 at 9:28













yes, @comphonia

– Bhawesh
Dec 29 '18 at 9:36





yes, @comphonia

– Bhawesh
Dec 29 '18 at 9:36













i am not getting you, can you explain more @jotaen

– Bhawesh
Dec 29 '18 at 9:38







i am not getting you, can you explain more @jotaen

– Bhawesh
Dec 29 '18 at 9:38














1 Answer
1






active

oldest

votes


















2















I just want to change user status from 0 to 1 automatically when the current date matches with exp_date.




Seems like you want :



UPDATE abc SET status = 1 WHERE exp_date < NOW();


Rather than checking specifically for the current date, this will reset all users that ever expired.



If you want to disable only users that expired today :



UPDATE abc SET status = 1 WHERE DATE(exp_date) = CUR_DATE();





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53968090%2fchange-user-status-from-0-to-1-after-6-months%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2















    I just want to change user status from 0 to 1 automatically when the current date matches with exp_date.




    Seems like you want :



    UPDATE abc SET status = 1 WHERE exp_date < NOW();


    Rather than checking specifically for the current date, this will reset all users that ever expired.



    If you want to disable only users that expired today :



    UPDATE abc SET status = 1 WHERE DATE(exp_date) = CUR_DATE();





    share|improve this answer




























      2















      I just want to change user status from 0 to 1 automatically when the current date matches with exp_date.




      Seems like you want :



      UPDATE abc SET status = 1 WHERE exp_date < NOW();


      Rather than checking specifically for the current date, this will reset all users that ever expired.



      If you want to disable only users that expired today :



      UPDATE abc SET status = 1 WHERE DATE(exp_date) = CUR_DATE();





      share|improve this answer


























        2












        2








        2








        I just want to change user status from 0 to 1 automatically when the current date matches with exp_date.




        Seems like you want :



        UPDATE abc SET status = 1 WHERE exp_date < NOW();


        Rather than checking specifically for the current date, this will reset all users that ever expired.



        If you want to disable only users that expired today :



        UPDATE abc SET status = 1 WHERE DATE(exp_date) = CUR_DATE();





        share|improve this answer














        I just want to change user status from 0 to 1 automatically when the current date matches with exp_date.




        Seems like you want :



        UPDATE abc SET status = 1 WHERE exp_date < NOW();


        Rather than checking specifically for the current date, this will reset all users that ever expired.



        If you want to disable only users that expired today :



        UPDATE abc SET status = 1 WHERE DATE(exp_date) = CUR_DATE();






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 29 '18 at 10:39









        GMBGMB

        8,0512522




        8,0512522






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53968090%2fchange-user-status-from-0-to-1-after-6-months%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas