|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-07-31 10:26 UTC] nic at bbmcarlson dot com
I have some code:
$nextmonth = strtotime("next month");
$monthafter = strtotime("next month",$nextmonth") ;
$monthOne = date("F") ;
$monthTwo=date("F",$nextmonth) ;
$monthThree=date("F",$monthafter) ;
Today is July 31 2002. I have the code:
print($monthOne) ;
print($monthTwo) ;
print($monthThree) ;
It prints: July, August, October
I expect it to print: July, August, September
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 19:00:01 2025 UTC |
In PHP 4.2.3, the difference between "2" and "next" are still screwy in strtotime(). I'm trying to parse icalendar recurrence formats, so I need to calculate things like the "second Monday" in a month. Sample code below illustrates the difference between "2" and "next" (which should be identical). <? $start = strtotime('September 1, 2002'); echo ('Start timestamp: '.$start.'<br>'); echo ('Start date: Sunday, Sep 1 2002<br>'); $first = strtotime('first Monday',$start); echo ('"First" Monday: '.date('l, M d Y',$first).'<br>'); $oneth = strtotime('1 Monday',$start); echo ('"1" Monday: '.date('l, M d Y',$oneth).'<br>'); $next = strtotime('next Monday',$start); echo ('"Next" Monday: '.date('l, M d Y',$next).'<br>'); $twoth = strtotime('2 Monday',$start); echo ('"2" Monday: '.date('l, M d Y',$twoth).'<br>'); $third = strtotime('third Monday',$start); echo ('"Third" Monday: '.date('l, M d Y',$third).'<br>'); $threeth = strtotime('3 Monday',$start); echo ('"3" Monday: '.date('l, M d Y',$threeth).'<br>'); ?>I also can confirm that strtotime acts funny when the same day does not exist in the next month: <? $timestamp = strtotime("31 October 2002"); $next_month = strftime("%B" ,strtotime("+1 month", $timestamp)); echo $next_month; ?> displays: DecemberI have noticed that when you do something like $sdate = date9'Y-m-d', strtotime('02-09-2003')); $sdate is getting '2008-02-24'. Is this a common occurance