Even more funny... I cut and pasted your code and I got;
Wed Dec 12 2001 Sat Mar 1 2003 2001-12-12 2001-03-01 What version of Php and OS are you using?? John "Niklas lampén" <[EMAIL PROTECTED]> wrote in message 000301c16369$6817a320$ba93c5c3@Niklas">news:000301c16369$6817a320$ba93c5c3@Niklas... > Funny, I quickly tried this: > > <? > $date1 = "12/12/2001"; > $date2 = "15/01/2002"; > > $date1 = date("D M j Y", strtotime($date1)); > $date2 = date("D M j Y", strtotime($date2)); > > print $date1."<br>"; > print $date2."<br>"; > > print date("Y-m-d", strtotime($date1))."<br>"; > print date("Y-m-d", strtotime($date2))."<br>"; > ?> > > And the result was this: > " > Wed Dec 12 2001 > Sat Mar 1 2003 > 2001-12-12 > 2003-03-01 > " > > > Niklas > > > -----Original Message----- > From: John Clarke [mailto:[EMAIL PROTECTED]] > Sent: 2. marraskuuta 2001 8:17 > To: [EMAIL PROTECTED] > Subject: [PHP] year 2002 strtotime problem > > > I have this problem with Php 4.0.5 on both Win ME and Linus boxes, > where my year 2002 dates are converted back to 2001 when formating with > 'strtotime'. > > First I post the following variables from an html page to a php page > > $date1='12/12/2001' > $date2='15/01/2002' > > I then use date("D M j Y", strtotime($date1); and date("D M j Y", > strtotime($date2)); to store them in an array for screen display. > > As the users have the abilty to selected different dates I need to check > that 1 is before the other. To do this I have a script timediff() that I > pass the two dates to in the above format. > > All works fine until the year 2002 is selected. This is part of the > timediff() code with dispay statements and the result. > > function timediff($date1,$date2) { > > echo 'date1= '."$date1".' '; // displays 'Wed > December 12 > 2001' ....... correct > echo 'date2= '."$date2".' '; // displays 'Tue > January 15 > 2002' ...........correct, all fine so far > > $dd1=date("Ymd", strtotime($date1)); > $dd2=date("Ymd", strtotime($date2)); > > echo 'date1= '.$dd1.'<br>'; // displays '20011212' > ....... > correct > echo 'date2= '.$dd2.' <br>'; // displays '20010115 > ...........WRONG > } > > It seem that by applying strtotime a 2nd time might cause this > problem, as the first application was fine. > > I have tested all possible combinations of strtotime but the year > 2002 always goes back to 2001 Have also tried just 'strtotime($date1)' > but same problem again. > > Any help or comments would be greatly appreciated as I thought I had > finished a booking program any now find this!! > > Thanks in anticipation > > > John Clarke > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] To > contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]