How to check date is exceeded 7 days in strtotime() in PHP










-3















Here I am written code for supposing resetAt is crossed 24 hrs means I have set passwordResetStatusto true, now I want to increase the time like resetAt is crossed 7 days means I have to set passwordResetStatusto true how can I achieve this



if(!empty($passwordReset['resetAt'])) 
$difference = strtotime(date(DATE_FORMAT)) - strtotime($passwordReset['resetAt']);
$interval = 60 * 60 * 24 * 7;
if($difference >= $interval)
$data['passwordResetStatus'] = true;
else
$data['passwordResetStatus'] = false;

//var_dump($data['passwordResetStatus']);




resetAt = 2018-11-08 10:38:55



today = 2018-11-14 10:45:55




based on above condition passwordResetStatus = true because 2018-11-08 to 2018-11-14 total 7 days consider time also today time is 10:45:55 reaetAt time 10:38:55 so today time exceeded resetAt time .




resetAt = 2018-11-08 10:38:55



today = 2018-11-14 10:30:55




based on above condition passwordResetStatus = false because 2018-11-08 to 2018-11-14 total 7 days consider time also today time is 10:30:55 reaetAt time 10:38:55 so today time not exceeded resetAt time.



We have to consider date & time










share|improve this question
























  • What is DATE_FORMAT ?

    – Osama Ibrahim
    Nov 13 '18 at 7:27











  • About that notice: how should we know what DATE_FORMAT should mean? Why did you put it there in the first place?

    – Nico Haase
    Nov 13 '18 at 7:27











  • @ Alive to Die, i have used to your code but not working , please top i have updated my code and response

    – Prasanna
    Nov 13 '18 at 7:27











  • @Osama Ibrahim, Y-m-d H:i:s

    – Prasanna
    Nov 13 '18 at 7:29











  • anyone update my answer separately

    – Prasanna
    Nov 13 '18 at 7:31















-3















Here I am written code for supposing resetAt is crossed 24 hrs means I have set passwordResetStatusto true, now I want to increase the time like resetAt is crossed 7 days means I have to set passwordResetStatusto true how can I achieve this



if(!empty($passwordReset['resetAt'])) 
$difference = strtotime(date(DATE_FORMAT)) - strtotime($passwordReset['resetAt']);
$interval = 60 * 60 * 24 * 7;
if($difference >= $interval)
$data['passwordResetStatus'] = true;
else
$data['passwordResetStatus'] = false;

//var_dump($data['passwordResetStatus']);




resetAt = 2018-11-08 10:38:55



today = 2018-11-14 10:45:55




based on above condition passwordResetStatus = true because 2018-11-08 to 2018-11-14 total 7 days consider time also today time is 10:45:55 reaetAt time 10:38:55 so today time exceeded resetAt time .




resetAt = 2018-11-08 10:38:55



today = 2018-11-14 10:30:55




based on above condition passwordResetStatus = false because 2018-11-08 to 2018-11-14 total 7 days consider time also today time is 10:30:55 reaetAt time 10:38:55 so today time not exceeded resetAt time.



We have to consider date & time










share|improve this question
























  • What is DATE_FORMAT ?

    – Osama Ibrahim
    Nov 13 '18 at 7:27











  • About that notice: how should we know what DATE_FORMAT should mean? Why did you put it there in the first place?

    – Nico Haase
    Nov 13 '18 at 7:27











  • @ Alive to Die, i have used to your code but not working , please top i have updated my code and response

    – Prasanna
    Nov 13 '18 at 7:27











  • @Osama Ibrahim, Y-m-d H:i:s

    – Prasanna
    Nov 13 '18 at 7:29











  • anyone update my answer separately

    – Prasanna
    Nov 13 '18 at 7:31













-3












-3








-3








Here I am written code for supposing resetAt is crossed 24 hrs means I have set passwordResetStatusto true, now I want to increase the time like resetAt is crossed 7 days means I have to set passwordResetStatusto true how can I achieve this



if(!empty($passwordReset['resetAt'])) 
$difference = strtotime(date(DATE_FORMAT)) - strtotime($passwordReset['resetAt']);
$interval = 60 * 60 * 24 * 7;
if($difference >= $interval)
$data['passwordResetStatus'] = true;
else
$data['passwordResetStatus'] = false;

//var_dump($data['passwordResetStatus']);




resetAt = 2018-11-08 10:38:55



today = 2018-11-14 10:45:55




based on above condition passwordResetStatus = true because 2018-11-08 to 2018-11-14 total 7 days consider time also today time is 10:45:55 reaetAt time 10:38:55 so today time exceeded resetAt time .




resetAt = 2018-11-08 10:38:55



today = 2018-11-14 10:30:55




based on above condition passwordResetStatus = false because 2018-11-08 to 2018-11-14 total 7 days consider time also today time is 10:30:55 reaetAt time 10:38:55 so today time not exceeded resetAt time.



We have to consider date & time










share|improve this question
















Here I am written code for supposing resetAt is crossed 24 hrs means I have set passwordResetStatusto true, now I want to increase the time like resetAt is crossed 7 days means I have to set passwordResetStatusto true how can I achieve this



if(!empty($passwordReset['resetAt'])) 
$difference = strtotime(date(DATE_FORMAT)) - strtotime($passwordReset['resetAt']);
$interval = 60 * 60 * 24 * 7;
if($difference >= $interval)
$data['passwordResetStatus'] = true;
else
$data['passwordResetStatus'] = false;

//var_dump($data['passwordResetStatus']);




resetAt = 2018-11-08 10:38:55



today = 2018-11-14 10:45:55




based on above condition passwordResetStatus = true because 2018-11-08 to 2018-11-14 total 7 days consider time also today time is 10:45:55 reaetAt time 10:38:55 so today time exceeded resetAt time .




resetAt = 2018-11-08 10:38:55



today = 2018-11-14 10:30:55




based on above condition passwordResetStatus = false because 2018-11-08 to 2018-11-14 total 7 days consider time also today time is 10:30:55 reaetAt time 10:38:55 so today time not exceeded resetAt time.



We have to consider date & time







php datetime






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 6:35







Prasanna

















asked Nov 13 '18 at 7:16









PrasannaPrasanna

838




838












  • What is DATE_FORMAT ?

    – Osama Ibrahim
    Nov 13 '18 at 7:27











  • About that notice: how should we know what DATE_FORMAT should mean? Why did you put it there in the first place?

    – Nico Haase
    Nov 13 '18 at 7:27











  • @ Alive to Die, i have used to your code but not working , please top i have updated my code and response

    – Prasanna
    Nov 13 '18 at 7:27











  • @Osama Ibrahim, Y-m-d H:i:s

    – Prasanna
    Nov 13 '18 at 7:29











  • anyone update my answer separately

    – Prasanna
    Nov 13 '18 at 7:31

















  • What is DATE_FORMAT ?

    – Osama Ibrahim
    Nov 13 '18 at 7:27











  • About that notice: how should we know what DATE_FORMAT should mean? Why did you put it there in the first place?

    – Nico Haase
    Nov 13 '18 at 7:27











  • @ Alive to Die, i have used to your code but not working , please top i have updated my code and response

    – Prasanna
    Nov 13 '18 at 7:27











  • @Osama Ibrahim, Y-m-d H:i:s

    – Prasanna
    Nov 13 '18 at 7:29











  • anyone update my answer separately

    – Prasanna
    Nov 13 '18 at 7:31
















What is DATE_FORMAT ?

– Osama Ibrahim
Nov 13 '18 at 7:27





What is DATE_FORMAT ?

– Osama Ibrahim
Nov 13 '18 at 7:27













About that notice: how should we know what DATE_FORMAT should mean? Why did you put it there in the first place?

– Nico Haase
Nov 13 '18 at 7:27





About that notice: how should we know what DATE_FORMAT should mean? Why did you put it there in the first place?

– Nico Haase
Nov 13 '18 at 7:27













@ Alive to Die, i have used to your code but not working , please top i have updated my code and response

– Prasanna
Nov 13 '18 at 7:27





@ Alive to Die, i have used to your code but not working , please top i have updated my code and response

– Prasanna
Nov 13 '18 at 7:27













@Osama Ibrahim, Y-m-d H:i:s

– Prasanna
Nov 13 '18 at 7:29





@Osama Ibrahim, Y-m-d H:i:s

– Prasanna
Nov 13 '18 at 7:29













anyone update my answer separately

– Prasanna
Nov 13 '18 at 7:31





anyone update my answer separately

– Prasanna
Nov 13 '18 at 7:31












1 Answer
1






active

oldest

votes


















2














Try This simple code



$passwordReset['resetAt'] = $restDate = "2018-11-6 11:58:55";
$newDate=date('Y-m-d H:i:s', strtotime($restDate.' +6 day'));
$currentDate=date('Y-m-d H:i:s');
if( isset( $passwordReset['resetAt'] ) && ($currentDate >= $newDate ))
$data['passwordResetStatus'] = true;
else
$data['passwordResetStatus'] = false;






share|improve this answer




















  • 1





    i tried your code but not working properly because i am getting Array ( [passwordResetStatus] => 1 ) but actual reault should come Array ( [passwordResetStatus] => 0 ) becase i have resetAt 2018-11-13 11:58:55 +7 days means 2018-11-20 11:58:55 then only Array ( [passwordResetStatus] => 1 ) correct but today is 2018-11-13 13:24:55

    – Prasanna
    Nov 13 '18 at 7:53












  • so you want resetAt date pluse 7 days with current date right?

    – Sachin
    Nov 13 '18 at 8:52











  • yes,kindly update your answer

    – Prasanna
    Nov 14 '18 at 5:12











  • your code also not working properly, please check my edited question

    – Prasanna
    Nov 14 '18 at 6:35











  • which issue you currently facing?

    – Sachin
    Nov 14 '18 at 6:39










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%2f53275735%2fhow-to-check-date-is-exceeded-7-days-in-strtotime-in-php%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














Try This simple code



$passwordReset['resetAt'] = $restDate = "2018-11-6 11:58:55";
$newDate=date('Y-m-d H:i:s', strtotime($restDate.' +6 day'));
$currentDate=date('Y-m-d H:i:s');
if( isset( $passwordReset['resetAt'] ) && ($currentDate >= $newDate ))
$data['passwordResetStatus'] = true;
else
$data['passwordResetStatus'] = false;






share|improve this answer




















  • 1





    i tried your code but not working properly because i am getting Array ( [passwordResetStatus] => 1 ) but actual reault should come Array ( [passwordResetStatus] => 0 ) becase i have resetAt 2018-11-13 11:58:55 +7 days means 2018-11-20 11:58:55 then only Array ( [passwordResetStatus] => 1 ) correct but today is 2018-11-13 13:24:55

    – Prasanna
    Nov 13 '18 at 7:53












  • so you want resetAt date pluse 7 days with current date right?

    – Sachin
    Nov 13 '18 at 8:52











  • yes,kindly update your answer

    – Prasanna
    Nov 14 '18 at 5:12











  • your code also not working properly, please check my edited question

    – Prasanna
    Nov 14 '18 at 6:35











  • which issue you currently facing?

    – Sachin
    Nov 14 '18 at 6:39















2














Try This simple code



$passwordReset['resetAt'] = $restDate = "2018-11-6 11:58:55";
$newDate=date('Y-m-d H:i:s', strtotime($restDate.' +6 day'));
$currentDate=date('Y-m-d H:i:s');
if( isset( $passwordReset['resetAt'] ) && ($currentDate >= $newDate ))
$data['passwordResetStatus'] = true;
else
$data['passwordResetStatus'] = false;






share|improve this answer




















  • 1





    i tried your code but not working properly because i am getting Array ( [passwordResetStatus] => 1 ) but actual reault should come Array ( [passwordResetStatus] => 0 ) becase i have resetAt 2018-11-13 11:58:55 +7 days means 2018-11-20 11:58:55 then only Array ( [passwordResetStatus] => 1 ) correct but today is 2018-11-13 13:24:55

    – Prasanna
    Nov 13 '18 at 7:53












  • so you want resetAt date pluse 7 days with current date right?

    – Sachin
    Nov 13 '18 at 8:52











  • yes,kindly update your answer

    – Prasanna
    Nov 14 '18 at 5:12











  • your code also not working properly, please check my edited question

    – Prasanna
    Nov 14 '18 at 6:35











  • which issue you currently facing?

    – Sachin
    Nov 14 '18 at 6:39













2












2








2







Try This simple code



$passwordReset['resetAt'] = $restDate = "2018-11-6 11:58:55";
$newDate=date('Y-m-d H:i:s', strtotime($restDate.' +6 day'));
$currentDate=date('Y-m-d H:i:s');
if( isset( $passwordReset['resetAt'] ) && ($currentDate >= $newDate ))
$data['passwordResetStatus'] = true;
else
$data['passwordResetStatus'] = false;






share|improve this answer















Try This simple code



$passwordReset['resetAt'] = $restDate = "2018-11-6 11:58:55";
$newDate=date('Y-m-d H:i:s', strtotime($restDate.' +6 day'));
$currentDate=date('Y-m-d H:i:s');
if( isset( $passwordReset['resetAt'] ) && ($currentDate >= $newDate ))
$data['passwordResetStatus'] = true;
else
$data['passwordResetStatus'] = false;







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 14 '18 at 6:46

























answered Nov 13 '18 at 7:41









SachinSachin

630411




630411







  • 1





    i tried your code but not working properly because i am getting Array ( [passwordResetStatus] => 1 ) but actual reault should come Array ( [passwordResetStatus] => 0 ) becase i have resetAt 2018-11-13 11:58:55 +7 days means 2018-11-20 11:58:55 then only Array ( [passwordResetStatus] => 1 ) correct but today is 2018-11-13 13:24:55

    – Prasanna
    Nov 13 '18 at 7:53












  • so you want resetAt date pluse 7 days with current date right?

    – Sachin
    Nov 13 '18 at 8:52











  • yes,kindly update your answer

    – Prasanna
    Nov 14 '18 at 5:12











  • your code also not working properly, please check my edited question

    – Prasanna
    Nov 14 '18 at 6:35











  • which issue you currently facing?

    – Sachin
    Nov 14 '18 at 6:39












  • 1





    i tried your code but not working properly because i am getting Array ( [passwordResetStatus] => 1 ) but actual reault should come Array ( [passwordResetStatus] => 0 ) becase i have resetAt 2018-11-13 11:58:55 +7 days means 2018-11-20 11:58:55 then only Array ( [passwordResetStatus] => 1 ) correct but today is 2018-11-13 13:24:55

    – Prasanna
    Nov 13 '18 at 7:53












  • so you want resetAt date pluse 7 days with current date right?

    – Sachin
    Nov 13 '18 at 8:52











  • yes,kindly update your answer

    – Prasanna
    Nov 14 '18 at 5:12











  • your code also not working properly, please check my edited question

    – Prasanna
    Nov 14 '18 at 6:35











  • which issue you currently facing?

    – Sachin
    Nov 14 '18 at 6:39







1




1





i tried your code but not working properly because i am getting Array ( [passwordResetStatus] => 1 ) but actual reault should come Array ( [passwordResetStatus] => 0 ) becase i have resetAt 2018-11-13 11:58:55 +7 days means 2018-11-20 11:58:55 then only Array ( [passwordResetStatus] => 1 ) correct but today is 2018-11-13 13:24:55

– Prasanna
Nov 13 '18 at 7:53






i tried your code but not working properly because i am getting Array ( [passwordResetStatus] => 1 ) but actual reault should come Array ( [passwordResetStatus] => 0 ) becase i have resetAt 2018-11-13 11:58:55 +7 days means 2018-11-20 11:58:55 then only Array ( [passwordResetStatus] => 1 ) correct but today is 2018-11-13 13:24:55

– Prasanna
Nov 13 '18 at 7:53














so you want resetAt date pluse 7 days with current date right?

– Sachin
Nov 13 '18 at 8:52





so you want resetAt date pluse 7 days with current date right?

– Sachin
Nov 13 '18 at 8:52













yes,kindly update your answer

– Prasanna
Nov 14 '18 at 5:12





yes,kindly update your answer

– Prasanna
Nov 14 '18 at 5:12













your code also not working properly, please check my edited question

– Prasanna
Nov 14 '18 at 6:35





your code also not working properly, please check my edited question

– Prasanna
Nov 14 '18 at 6:35













which issue you currently facing?

– Sachin
Nov 14 '18 at 6:39





which issue you currently facing?

– Sachin
Nov 14 '18 at 6:39

















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%2f53275735%2fhow-to-check-date-is-exceeded-7-days-in-strtotime-in-php%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







這個網誌中的熱門文章

What does pagestruct do in Eviews?

Dutch intervention in Lombok and Karangasem

Channel Islands