BODEKA Posted October 31, 2006 Share Posted October 31, 2006 I am having poblem with dates.When I run the following code how come I get$today-$yesterday: 25 hoursand$tomorrow-$today: 24 hours--------------------------------<?php$now = time();$today = mktime(0, 0, 0, date("m", $now) , date("d", $now), date("Y", $now));$yesterday = mktime(0, 0, 0, date("m", $now) , date("d", $now)-1, date("Y", $now));$tomorrow = mktime(0, 0, 0, date("m", $now) , date("d", $now)+1, date("Y", $now));echo "today-yesterday: ".($today-$yesterday)/$hour." hours"."<br />";echo "tomorrow-today: ".($tomorrow-$today)/$hour." hours"."<br />";?> Link to comment https://forums.phpfreaks.com/topic/25646-problem-with-dates/ Share on other sites More sharing options...
Caesar Posted October 31, 2006 Share Posted October 31, 2006 Not sure what it is you're trying to do but...try this to get you started:[code]<?php$today = time();$yesterday = ($today - 86400);$diference = (($today - $yesterday) / 60) / 60;print_r($diference);?>[/code]Maybe if you explained what you're trying to do...? Link to comment https://forums.phpfreaks.com/topic/25646-problem-with-dates/#findComment-117077 Share on other sites More sharing options...
BODEKA Posted October 31, 2006 Author Share Posted October 31, 2006 How come one deduction gives me 24 hours difference as I expect it to bebut the other one gives me 25 hours difference.I forgot: $hour = 3600; Link to comment https://forums.phpfreaks.com/topic/25646-problem-with-dates/#findComment-117124 Share on other sites More sharing options...
kenrbnsn Posted October 31, 2006 Share Posted October 31, 2006 If you're in the US, yesterday, October 29th, had 25 hours due to the switch from Daylight Saving to Standard time.Ken Link to comment https://forums.phpfreaks.com/topic/25646-problem-with-dates/#findComment-117126 Share on other sites More sharing options...
BODEKA Posted October 31, 2006 Author Share Posted October 31, 2006 Thanks Ken, I completely forgot about time switch. Link to comment https://forums.phpfreaks.com/topic/25646-problem-with-dates/#findComment-117146 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.