Re: [PHP] Year

2007-02-02 Thread Robert Cummings
On Fri, 2007-02-02 at 10:11 -0500, Dan Shirah wrote:
 Hello all,
 
 I am trying to populate a dropdown list to contain the current year to 10
 years in the future.  Below is the code I'm using:
 
 ?PHP
   for ($y=0;$y=10;$y++) {
   $years=date http://php.net/date('Y')+$y;
   $short_years=date http://php.net/date('y')+$y;
   echo $short_years;
   echo option value=\$short_years\$years/option;
   }
 ?
 I want the selection value to be 2007, 2008, 2009, 2010  and the $years
 accomplishes this.  Howeverm I want the option value to be the two digit
 year ex. 07, 08, 09, 10...the $short_years semi accomplishes thisinstead
 of getting 07, 08, 08, 10 I get 7, 8, 9, 10...how can I get it to output the
 two year for 07, 08, 09 without it cutting off the zero?

?php

$year = date( 'Y' );
for( $i = 0; $i  10; $i++ )
{
$iYear = substr( (string)($year + 1), 2 );
echo 'option value='.$iYear.''.$iYear.'/option';
}

?

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Year

2007-02-02 Thread Robert Cummings
On Fri, 2007-02-02 at 10:21 -0500, Robert Cummings wrote:
 On Fri, 2007-02-02 at 10:11 -0500, Dan Shirah wrote:
  Hello all,
  
  I am trying to populate a dropdown list to contain the current year to 10
  years in the future.  Below is the code I'm using:
  
  ?PHP
for ($y=0;$y=10;$y++) {
$years=date http://php.net/date('Y')+$y;
$short_years=date http://php.net/date('y')+$y;
echo $short_years;
echo option value=\$short_years\$years/option;
}
  ?
  I want the selection value to be 2007, 2008, 2009, 2010  and the $years
  accomplishes this.  Howeverm I want the option value to be the two digit
  year ex. 07, 08, 09, 10...the $short_years semi accomplishes thisinstead
  of getting 07, 08, 08, 10 I get 7, 8, 9, 10...how can I get it to output the
  two year for 07, 08, 09 without it cutting off the zero?
 
 ?php
 
 $year = date( 'Y' );
 for( $i = 0; $i  10; $i++ )
 {
 $iYear = substr( (string)($year + 1), 2 );
 echo 'option value='.$iYear.''.$iYear.'/option';
 }
 
 ?

Bleh... Typo in the above... so here's a better one :)

?php

$currYear = date( 'Y' );
for( $i = 0; $i  10; $i++ )
{
$longYear  = $currYear + $i;
$shortYear = substr( (string)$longYear, 2 );
echo 'option value='.$shortYear.''.$longYear.'/option';
}

?

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Year

2007-02-02 Thread Németh Zoltán
On p, 2007-02-02 at 10:11 -0500, Dan Shirah wrote:
 Hello all,
 
 I am trying to populate a dropdown list to contain the current year to 10
 years in the future.  Below is the code I'm using:
 
 ?PHP
   for ($y=0;$y=10;$y++) {
   $years=date http://php.net/date('Y')+$y;
   $short_years=date http://php.net/date('y')+$y;
   echo $short_years;
   echo option value=\$short_years\$years/option;
   }
 ?
 I want the selection value to be 2007, 2008, 2009, 2010  and the $years
 accomplishes this.  Howeverm I want the option value to be the two digit
 year ex. 07, 08, 09, 10...the $short_years semi accomplishes thisinstead
 of getting 07, 08, 08, 10 I get 7, 8, 9, 10...how can I get it to output the
 two year for 07, 08, 09 without it cutting off the zero?

I think it is because when you calculate $short_years it is an integer.
So insert the following before echoing it out:

if ($short_years  10) {$short_years = 0 . $short_years;}

hope that helps
Zoltán Németh

 
 Reagrds,
 
 Dan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Year

2007-02-02 Thread chetan rane

HI Dan

try this this should work 100%;

echo select;
for ($y=0;$y=10;$y++) {
$years=date('Y')+$y;
$short_years=date('y')+$y;
printf(option value=\%02d\%d/option,$short_years,$years);

}
echo /select;

On 2/2/07, Dan Shirah [EMAIL PROTECTED] wrote:


Hello all,

I am trying to populate a dropdown list to contain the current year to 10
years in the future.  Below is the code I'm using:

?PHP
  for ($y=0;$y=10;$y++) {
  $years=date http://php.net/date('Y')+$y;
  $short_years=date http://php.net/date('y')+$y;
  echo $short_years;
  echo option value=\$short_years\$years/option;
  }
?
I want the selection value to be 2007, 2008, 2009, 2010  and the
$years
accomplishes this.  Howeverm I want the option value to be the two digit
year ex. 07, 08, 09, 10...the $short_years semi accomplishes
thisinstead
of getting 07, 08, 08, 10 I get 7, 8, 9, 10...how can I get it to output
the
two year for 07, 08, 09 without it cutting off the zero?

Reagrds,

Dan





--
Have A plesant Day
Chetan. D. Rane
Location: Pune , India
Contact: +91-9890792762
otherID: [EMAIL PROTECTED]
[EMAIL PROTECTED]


Re: [PHP] Year

2007-02-02 Thread Dan Shirah

Thanks everyone!  A lot of great solutions!

On 2/2/07, chetan rane [EMAIL PROTECTED] wrote:


HI Dan

try this this should work 100%;

echo select;
for ($y=0;$y=10;$y++) {
$years=date('Y')+$y;
$short_years=date('y')+$y;
printf(option value=\%02d\%d/option,$short_years,$years);

}
echo /select;

On 2/2/07, Dan Shirah [EMAIL PROTECTED] wrote:

 Hello all,

 I am trying to populate a dropdown list to contain the current year to
10
 years in the future.  Below is the code I'm using:

 ?PHP
   for ($y=0;$y=10;$y++) {
   $years=date http://php.net/date('Y')+$y;
   $short_years=date http://php.net/date('y')+$y;
   echo $short_years;
   echo option value=\$short_years\$years/option;
   }
 ?
 I want the selection value to be 2007, 2008, 2009, 2010  and the
 $years
 accomplishes this.  Howeverm I want the option value to be the two digit
 year ex. 07, 08, 09, 10...the $short_years semi accomplishes
 thisinstead
 of getting 07, 08, 08, 10 I get 7, 8, 9, 10...how can I get it to output
 the
 two year for 07, 08, 09 without it cutting off the zero?

 Reagrds,

 Dan




--
Have A plesant Day
Chetan. D. Rane
Location: Pune , India
Contact: +91-9890792762
otherID: [EMAIL PROTECTED]
[EMAIL PROTECTED]




Re: [PHP] Year

2007-02-02 Thread Richard Lynch
On Fri, February 2, 2007 9:11 am, Dan Shirah wrote:
 I am trying to populate a dropdown list to contain the current year to
 10
 years in the future.  Below is the code I'm using:

 ?PHP
   for ($y=0;$y=10;$y++) {
   $years=date http://php.net/date('Y')+$y;
   $short_years=date http://php.net/date('y')+$y;
   echo $short_years;
   echo option value=\$short_years\$years/option;
   }
 ?
 I want the selection value to be 2007, 2008, 2009, 2010  and the
 $years
 accomplishes this.  Howeverm I want the option value to be the two
 digit
 year ex. 07, 08, 09, 10...the $short_years semi accomplishes
 thisinstead
 of getting 07, 08, 08, 10 I get 7, 8, 9, 10...how can I get it to
 output the
 two year for 07, 08, 09 without it cutting off the zero?

for ($year = date('Y'); $year = date('Y') + 10; $year++){
  $short_year = $year - 2000;
  echo option value=\$short_year\$year/option\n;
}

Using the 2-digit year as your value is almost for sure a really Bad
Idea, unless you are dealing with legacy software that absolutely
needs it...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Year

2007-02-02 Thread Robert Cummings
On Fri, 2007-02-02 at 19:02 -0600, Richard Lynch wrote:
 On Fri, February 2, 2007 9:11 am, Dan Shirah wrote:
  I am trying to populate a dropdown list to contain the current year to
  10
  years in the future.  Below is the code I'm using:
 
  ?PHP
for ($y=0;$y=10;$y++) {
$years=date http://php.net/date('Y')+$y;
$short_years=date http://php.net/date('y')+$y;
echo $short_years;
echo option value=\$short_years\$years/option;
}
  ?
  I want the selection value to be 2007, 2008, 2009, 2010  and the
  $years
  accomplishes this.  Howeverm I want the option value to be the two
  digit
  year ex. 07, 08, 09, 10...the $short_years semi accomplishes
  thisinstead
  of getting 07, 08, 08, 10 I get 7, 8, 9, 10...how can I get it to
  output the
  two year for 07, 08, 09 without it cutting off the zero?
 
 for ($year = date('Y'); $year = date('Y') + 10; $year++){
   $short_year = $year - 2000;
   echo option value=\$short_year\$year/option\n;
 }
 
 Using the 2-digit year as your value is almost for sure a really Bad
 Idea, unless you are dealing with legacy software that absolutely
 needs it...

Sorry Richard, you solution fails since he wants to retain the leading
zeros on the 2 digit years. Using subtraction and not formatting the
result will result in the loss of the 0 in 07. Also, why call the date()
function 10 times by embedding it in the loop's terminate condition?

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Year

2007-02-02 Thread Richard Lynch
On Fri, February 2, 2007 7:41 pm, Robert Cummings wrote:
 for ($year = date('Y'); $year = date('Y') + 10; $year++){
   $short_year = $year - 2000;

$short_year = sprintf('%02d', $short_year);

   echo option value=\$short_year\$year/option\n;
 }

 Using the 2-digit year as your value is almost for sure a really Bad
 Idea, unless you are dealing with legacy software that absolutely
 needs it...

 Sorry Richard, you solution fails since he wants to retain the leading
 zeros on the 2 digit years. Using subtraction and not formatting the
 result will result in the loss of the 0 in 07. Also, why call the
 date()
 function 10 times by embedding it in the loop's terminate condition?

Because 10 calls to date() is chump-change.

If you need to optimize away 10 calls to date() then something is
horribly wrong...

That said, it's pretty trivial to optimize it:
for ($year = date('Y'), $end = date('Y) + 10; $year = $end; $year++){

If PHP guarantees the order of operations in for(, ; ; ) you could
even use $year instead of date('Y) on the $end assignment.  That's
really getting silly about optimization, however.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Year

2007-02-02 Thread Robert Cummings
On Fri, 2007-02-02 at 20:08 -0600, Richard Lynch wrote:
 On Fri, February 2, 2007 7:41 pm, Robert Cummings wrote:
  function 10 times by embedding it in the loop's terminate condition?
 
 Because 10 calls to date() is chump-change.

10 chumps here, 10 there, 100 there, sloppy here, sloppy there, didn't
realize this call isn't chump change, a million there. It adds up.

 If you need to optimize away 10 calls to date() then something is
 horribly wrong...

No, but implicitly understanding wasted cycles will make it a habit you
don't need to think about.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] year 2002 strtotime problem

2001-11-01 Thread Niklas Lampén

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]




Re: [PHP] year 2002 strtotime problem

2001-11-01 Thread John Clarke

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]




RE: [PHP] year 2002 strtotime problem

2001-11-01 Thread Niklas Lampén

Great. :)

I've got PHP 4.0.6 on linux. You?

I think you should break the dates manually, it would be the most sure
way to do it.


Niklas


-Original Message-
From: John Clarke [mailto:[EMAIL PROTECTED]] 
Sent: 2. marraskuuta 2001 9:11
To: [EMAIL PROTECTED]
Subject: Re: [PHP] year 2002 strtotime problem


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]


--
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]




Re: [PHP] year 2002 strtotime problem

2001-11-01 Thread John Clarke

I'm still running 4.0.5 because that is what my web host is running.
Methinks there may be a problem here.

In the meantime I've tried storing the dates in the array in the original
format in lieu of the fully converted format.
I then reformat the original from the array as required for each page
display or time difference calculation.
This works fine, so I might stick with it.
In hindsight, it is probaly the way I should have gone in the first place as
you pointed out. That way I can play with the date, month and year any way I
want.

Thanks for you input.

John


Niklas lampén [EMAIL PROTECTED] wrote in message
000401c1636f$fd37d960$ba93c5c3@Niklas">news:000401c1636f$fd37d960$ba93c5c3@Niklas...
Great. :)

I've got PHP 4.0.6 on linux. You?

I think you should break the dates manually, it would be the most sure
way to do it.


Niklas


-Original Message-
From: John Clarke [mailto:[EMAIL PROTECTED]]
Sent: 2. marraskuuta 2001 9:11
To: [EMAIL PROTECTED]
Subject: Re: [PHP] year 2002 strtotime problem


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]




-- 
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]