RE: date conversions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm



On 16 December 2004 06:00, neil wrote:

> Hi
> 
> I am needing to convert a d/m/y date such as 30/11/2004 into the
> format that mysql can use ie. 2004-11-20
> 
> If I try the following:
> 
> $testdate="30/11/2004";
> echo date("Y-m-d", strtotime($testdate));
> 
> the result is - 2006-06-11

strtotime() is, unfortunately, a little American biased and only recognises
the mm/dd/yyyy numeric format (using slashes).  So the above is returning
the equivalent of the 11th day of the 30th month of 2004!

You can use other PHP functions, as has been suggested, but you might also
investigate the mySQL date formatting functions, as I believe they work
perfectly well on input dates as well as output ones.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux