FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » strtotime() not able to handle 04/29 correctly???
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
strtotime() not able to handle 04/29 correctly??? [message #177220] Wed, 29 February 2012 18:41 Go to previous message
cerr is currently offline  cerr
Messages: 33
Registered: September 2010
Karma:
Member
Hi,

I calculate the amount of days between two dates like this:

$start = strtotime($_SESSION['sdate']);
$end = strtotime($_SESSION['hdate']);
echo ($end - $start);
$duration = ($end - $start) / 3600 /24;
$duration+=1; //plus one day
echo " The ad will show for ".$duration." day(s)<br/>";

Which generally works fine but things seem to mess up when I have a
start sdate of 2012-02-29 and an hdate of 2012-04-01. I get a duration
of: 32.9583333333
Why is this? That's messing up my calculations. Is there a better way
to do this?

Thanks!
Ron
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Is there a way to distinguish an auto-refresh from a manual page load?
Next Topic: CrowdFinch Technologies
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 21:07:49 GMT 2024

Total time taken to generate the page: 0.04219 seconds