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
Re: strtotime() not able to handle 04/29 correctly??? [message #177223 is a reply to message #177220] Wed, 29 February 2012 23:24 Go to previous messageGo to previous message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma:
Senior Member
cerr <ron(dot)eggler(at)gmail(dot)com> wrote in news:a63a7827-bc1a-483a-96ae-de8289aa2de0@
32g2000yqn.googlegroups.com:

> 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

which is 32 days 23 hours. What might throw this off by one hour? Hint: in the United States, it
happens every year on the second Sunday of March.
[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: Fri Nov 22 14:05:33 GMT 2024

Total time taken to generate the page: 0.04618 seconds