Here i want to +7 days into seconds,i written the code but not working properly












0















I want to convert +7 days into seconds. I have written the code but it is not working properly



    <?php
date_default_timezone_set('Asia/Kolkata');
$passwordReset['resetAt'] = "2018-11-20 12:10:55";
$duration = 60 * 60 * 24 * 7 ; // +7 days in seconds 60 * 60 * 24 * 7 = 604800
$currentTime = "2018-11-26 12:11:55" ;
if( isset( $passwordReset['resetAt'] ) && (strtotime($currentTime) - strtotime($passwordReset['resetAt'])) <= $duration ){
$data['passwordResetStatus'] = true;
}else{
$data['passwordResetStatus'] = false;
}
var_dump($data);
?>



resetAt = 2018-11-20 12:10:55



currentTime = 2018-11-26 12:11:55




Based on above conditions passwordResetStatus = false because 2018-11-20 to 2018-11-20 total 7 days consider time also currentTime is 12:11:55 resetAt time 12:10:55 so currentTime exceeded resetAt time.



Current result



array(1) { ["passwordResetStatus"]=> bool(true) }


Expected Result



array(1) { ["passwordResetStatus"]=> bool(false) }









share|improve this question




















  • 1





    But isn't 2018-11-20 to 2018-11-26 only six days?

    – Nigel Ren
    Nov 26 '18 at 7:18











  • @NigelRen surely not if you are counting both the 20th and the 26th as full days? i.e. Tuesday to Monday? Or am I misunderstanding something here?

    – Frits
    Nov 26 '18 at 7:21













  • @Frits (it's early for me) they want to know if 7 days worth of seconds have passed since the first date/time. So they aren't considering them as full days but the actual time passed.

    – Nigel Ren
    Nov 26 '18 at 7:27











  • @NigelRen Makes sense. So from 2018-11-20 00:00 to 2018-11-26 00:00 would be 6 days.

    – Frits
    Nov 26 '18 at 7:28













  • Didn't you ask a very similar question last week? Also 60 * 60 * 24 * 7 is not always a week due to DST. EDIT, you asked the "same" question twice before. once last week and once two weeks ago.

    – Andreas
    Nov 26 '18 at 7:52


















0















I want to convert +7 days into seconds. I have written the code but it is not working properly



    <?php
date_default_timezone_set('Asia/Kolkata');
$passwordReset['resetAt'] = "2018-11-20 12:10:55";
$duration = 60 * 60 * 24 * 7 ; // +7 days in seconds 60 * 60 * 24 * 7 = 604800
$currentTime = "2018-11-26 12:11:55" ;
if( isset( $passwordReset['resetAt'] ) && (strtotime($currentTime) - strtotime($passwordReset['resetAt'])) <= $duration ){
$data['passwordResetStatus'] = true;
}else{
$data['passwordResetStatus'] = false;
}
var_dump($data);
?>



resetAt = 2018-11-20 12:10:55



currentTime = 2018-11-26 12:11:55




Based on above conditions passwordResetStatus = false because 2018-11-20 to 2018-11-20 total 7 days consider time also currentTime is 12:11:55 resetAt time 12:10:55 so currentTime exceeded resetAt time.



Current result



array(1) { ["passwordResetStatus"]=> bool(true) }


Expected Result



array(1) { ["passwordResetStatus"]=> bool(false) }









share|improve this question




















  • 1





    But isn't 2018-11-20 to 2018-11-26 only six days?

    – Nigel Ren
    Nov 26 '18 at 7:18











  • @NigelRen surely not if you are counting both the 20th and the 26th as full days? i.e. Tuesday to Monday? Or am I misunderstanding something here?

    – Frits
    Nov 26 '18 at 7:21













  • @Frits (it's early for me) they want to know if 7 days worth of seconds have passed since the first date/time. So they aren't considering them as full days but the actual time passed.

    – Nigel Ren
    Nov 26 '18 at 7:27











  • @NigelRen Makes sense. So from 2018-11-20 00:00 to 2018-11-26 00:00 would be 6 days.

    – Frits
    Nov 26 '18 at 7:28













  • Didn't you ask a very similar question last week? Also 60 * 60 * 24 * 7 is not always a week due to DST. EDIT, you asked the "same" question twice before. once last week and once two weeks ago.

    – Andreas
    Nov 26 '18 at 7:52
















0












0








0








I want to convert +7 days into seconds. I have written the code but it is not working properly



    <?php
date_default_timezone_set('Asia/Kolkata');
$passwordReset['resetAt'] = "2018-11-20 12:10:55";
$duration = 60 * 60 * 24 * 7 ; // +7 days in seconds 60 * 60 * 24 * 7 = 604800
$currentTime = "2018-11-26 12:11:55" ;
if( isset( $passwordReset['resetAt'] ) && (strtotime($currentTime) - strtotime($passwordReset['resetAt'])) <= $duration ){
$data['passwordResetStatus'] = true;
}else{
$data['passwordResetStatus'] = false;
}
var_dump($data);
?>



resetAt = 2018-11-20 12:10:55



currentTime = 2018-11-26 12:11:55




Based on above conditions passwordResetStatus = false because 2018-11-20 to 2018-11-20 total 7 days consider time also currentTime is 12:11:55 resetAt time 12:10:55 so currentTime exceeded resetAt time.



Current result



array(1) { ["passwordResetStatus"]=> bool(true) }


Expected Result



array(1) { ["passwordResetStatus"]=> bool(false) }









share|improve this question
















I want to convert +7 days into seconds. I have written the code but it is not working properly



    <?php
date_default_timezone_set('Asia/Kolkata');
$passwordReset['resetAt'] = "2018-11-20 12:10:55";
$duration = 60 * 60 * 24 * 7 ; // +7 days in seconds 60 * 60 * 24 * 7 = 604800
$currentTime = "2018-11-26 12:11:55" ;
if( isset( $passwordReset['resetAt'] ) && (strtotime($currentTime) - strtotime($passwordReset['resetAt'])) <= $duration ){
$data['passwordResetStatus'] = true;
}else{
$data['passwordResetStatus'] = false;
}
var_dump($data);
?>



resetAt = 2018-11-20 12:10:55



currentTime = 2018-11-26 12:11:55




Based on above conditions passwordResetStatus = false because 2018-11-20 to 2018-11-20 total 7 days consider time also currentTime is 12:11:55 resetAt time 12:10:55 so currentTime exceeded resetAt time.



Current result



array(1) { ["passwordResetStatus"]=> bool(true) }


Expected Result



array(1) { ["passwordResetStatus"]=> bool(false) }






php date strtotime






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 9:07









BDL

14.7k63441




14.7k63441










asked Nov 26 '18 at 7:15









PrasannaPrasanna

838




838








  • 1





    But isn't 2018-11-20 to 2018-11-26 only six days?

    – Nigel Ren
    Nov 26 '18 at 7:18











  • @NigelRen surely not if you are counting both the 20th and the 26th as full days? i.e. Tuesday to Monday? Or am I misunderstanding something here?

    – Frits
    Nov 26 '18 at 7:21













  • @Frits (it's early for me) they want to know if 7 days worth of seconds have passed since the first date/time. So they aren't considering them as full days but the actual time passed.

    – Nigel Ren
    Nov 26 '18 at 7:27











  • @NigelRen Makes sense. So from 2018-11-20 00:00 to 2018-11-26 00:00 would be 6 days.

    – Frits
    Nov 26 '18 at 7:28













  • Didn't you ask a very similar question last week? Also 60 * 60 * 24 * 7 is not always a week due to DST. EDIT, you asked the "same" question twice before. once last week and once two weeks ago.

    – Andreas
    Nov 26 '18 at 7:52
















  • 1





    But isn't 2018-11-20 to 2018-11-26 only six days?

    – Nigel Ren
    Nov 26 '18 at 7:18











  • @NigelRen surely not if you are counting both the 20th and the 26th as full days? i.e. Tuesday to Monday? Or am I misunderstanding something here?

    – Frits
    Nov 26 '18 at 7:21













  • @Frits (it's early for me) they want to know if 7 days worth of seconds have passed since the first date/time. So they aren't considering them as full days but the actual time passed.

    – Nigel Ren
    Nov 26 '18 at 7:27











  • @NigelRen Makes sense. So from 2018-11-20 00:00 to 2018-11-26 00:00 would be 6 days.

    – Frits
    Nov 26 '18 at 7:28













  • Didn't you ask a very similar question last week? Also 60 * 60 * 24 * 7 is not always a week due to DST. EDIT, you asked the "same" question twice before. once last week and once two weeks ago.

    – Andreas
    Nov 26 '18 at 7:52










1




1





But isn't 2018-11-20 to 2018-11-26 only six days?

– Nigel Ren
Nov 26 '18 at 7:18





But isn't 2018-11-20 to 2018-11-26 only six days?

– Nigel Ren
Nov 26 '18 at 7:18













@NigelRen surely not if you are counting both the 20th and the 26th as full days? i.e. Tuesday to Monday? Or am I misunderstanding something here?

– Frits
Nov 26 '18 at 7:21







@NigelRen surely not if you are counting both the 20th and the 26th as full days? i.e. Tuesday to Monday? Or am I misunderstanding something here?

– Frits
Nov 26 '18 at 7:21















@Frits (it's early for me) they want to know if 7 days worth of seconds have passed since the first date/time. So they aren't considering them as full days but the actual time passed.

– Nigel Ren
Nov 26 '18 at 7:27





@Frits (it's early for me) they want to know if 7 days worth of seconds have passed since the first date/time. So they aren't considering them as full days but the actual time passed.

– Nigel Ren
Nov 26 '18 at 7:27













@NigelRen Makes sense. So from 2018-11-20 00:00 to 2018-11-26 00:00 would be 6 days.

– Frits
Nov 26 '18 at 7:28







@NigelRen Makes sense. So from 2018-11-20 00:00 to 2018-11-26 00:00 would be 6 days.

– Frits
Nov 26 '18 at 7:28















Didn't you ask a very similar question last week? Also 60 * 60 * 24 * 7 is not always a week due to DST. EDIT, you asked the "same" question twice before. once last week and once two weeks ago.

– Andreas
Nov 26 '18 at 7:52







Didn't you ask a very similar question last week? Also 60 * 60 * 24 * 7 is not always a week due to DST. EDIT, you asked the "same" question twice before. once last week and once two weeks ago.

– Andreas
Nov 26 '18 at 7:52














1 Answer
1






active

oldest

votes


















0














you are putting the wrong date:-



$currentTime = "2018-11-26 12:11:55" ; // 6 days


Right date is :-



$currentTime = "2018-11-27 12:11:55" ; // 7 days




<?php
date_default_timezone_set('Asia/Kolkata');
$passwordReset['resetAt'] = "2018-11-20 12:10:55";
$duration = 60 * 60 * 24 * 7 ; // +7 days in seconds 60 * 60 * 24 * 7 = 604800
$currentTime = "2018-11-27 12:11:55" ;

if( isset( $passwordReset['resetAt'] ) && (strtotime($currentTime) - strtotime($passwordReset['resetAt'])) <= $duration ){
$data['passwordResetStatus'] = true;
}else{
$data['passwordResetStatus'] = false;
}
var_dump($data);
?>





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%2f53476272%2fhere-i-want-to-7-days-into-seconds-i-written-the-code-but-not-working-properly%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









    0














    you are putting the wrong date:-



    $currentTime = "2018-11-26 12:11:55" ; // 6 days


    Right date is :-



    $currentTime = "2018-11-27 12:11:55" ; // 7 days




    <?php
    date_default_timezone_set('Asia/Kolkata');
    $passwordReset['resetAt'] = "2018-11-20 12:10:55";
    $duration = 60 * 60 * 24 * 7 ; // +7 days in seconds 60 * 60 * 24 * 7 = 604800
    $currentTime = "2018-11-27 12:11:55" ;

    if( isset( $passwordReset['resetAt'] ) && (strtotime($currentTime) - strtotime($passwordReset['resetAt'])) <= $duration ){
    $data['passwordResetStatus'] = true;
    }else{
    $data['passwordResetStatus'] = false;
    }
    var_dump($data);
    ?>





    share|improve this answer




























      0














      you are putting the wrong date:-



      $currentTime = "2018-11-26 12:11:55" ; // 6 days


      Right date is :-



      $currentTime = "2018-11-27 12:11:55" ; // 7 days




      <?php
      date_default_timezone_set('Asia/Kolkata');
      $passwordReset['resetAt'] = "2018-11-20 12:10:55";
      $duration = 60 * 60 * 24 * 7 ; // +7 days in seconds 60 * 60 * 24 * 7 = 604800
      $currentTime = "2018-11-27 12:11:55" ;

      if( isset( $passwordReset['resetAt'] ) && (strtotime($currentTime) - strtotime($passwordReset['resetAt'])) <= $duration ){
      $data['passwordResetStatus'] = true;
      }else{
      $data['passwordResetStatus'] = false;
      }
      var_dump($data);
      ?>





      share|improve this answer


























        0












        0








        0







        you are putting the wrong date:-



        $currentTime = "2018-11-26 12:11:55" ; // 6 days


        Right date is :-



        $currentTime = "2018-11-27 12:11:55" ; // 7 days




        <?php
        date_default_timezone_set('Asia/Kolkata');
        $passwordReset['resetAt'] = "2018-11-20 12:10:55";
        $duration = 60 * 60 * 24 * 7 ; // +7 days in seconds 60 * 60 * 24 * 7 = 604800
        $currentTime = "2018-11-27 12:11:55" ;

        if( isset( $passwordReset['resetAt'] ) && (strtotime($currentTime) - strtotime($passwordReset['resetAt'])) <= $duration ){
        $data['passwordResetStatus'] = true;
        }else{
        $data['passwordResetStatus'] = false;
        }
        var_dump($data);
        ?>





        share|improve this answer













        you are putting the wrong date:-



        $currentTime = "2018-11-26 12:11:55" ; // 6 days


        Right date is :-



        $currentTime = "2018-11-27 12:11:55" ; // 7 days




        <?php
        date_default_timezone_set('Asia/Kolkata');
        $passwordReset['resetAt'] = "2018-11-20 12:10:55";
        $duration = 60 * 60 * 24 * 7 ; // +7 days in seconds 60 * 60 * 24 * 7 = 604800
        $currentTime = "2018-11-27 12:11:55" ;

        if( isset( $passwordReset['resetAt'] ) && (strtotime($currentTime) - strtotime($passwordReset['resetAt'])) <= $duration ){
        $data['passwordResetStatus'] = true;
        }else{
        $data['passwordResetStatus'] = false;
        }
        var_dump($data);
        ?>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 26 '18 at 7:36









        Parvej AlamParvej Alam

        2167




        2167






























            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%2f53476272%2fhere-i-want-to-7-days-into-seconds-i-written-the-code-but-not-working-properly%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

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)