RE: [PHP-DB] question regarding date format
| From: | Smita Manohar | Date: | Wed, 18 Sep 2002 06:14:38 +0000 |
| Subject: | RE: [PHP-DB] question regarding date format | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-21820@lists.php.net to get a copy of this message | ||
Jim, Mike :
thanks for reply.
getting desire result with strtotime.
John,
yess u r right.
sometimes in my script date is coming from database. in that case, use of DATE_FORMAT() is the best option.
thanks
smita.
_________________________________________________________________ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.comFrom: "Ford, Mike [LSS]" <M.Ford@lmu.ac.uk>To: 'Smita Manohar' <smitamanohar@hotmail.com>, php-db@lists.php.net Subject: RE: [PHP-DB] question regarding date format Date: Mon, 16 Sep 2002 18:40:06 +0100 -----Original Message----- From: Smita Manohar [mailto:smitamanohar@hotmail.com] Sent: 16 September 2002 18:11 hi all, a simple question regarding date, but i stuck with it . havin a variable containing date as, $date_test = "2002-08-02"; now i want it should be printed like, August 02, 2002 i am doing this with the funcion : echo date("F d, Y", $date_test); but getting a strange result as, January 01, 1970 The date() function takes a timestamp as its second argument, so you have to convert your textual date before passing it to date(). With the format you have, strtotime should work, so try date("F d, Y", strtotime($date_test)) (P.S. You get January 01, 1970 because PHP converts "2002-08-02" to the number 2002 before passing it to date() -- and this represents about 0:33 on that date!) Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.ukTel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211