RE: [PHP-DB] question regarding date format
| From: | Ford, Mike [LSS] | Date: | Mon, 16 Sep 2002 17:40:06 +0000 |
| Subject: | RE: [PHP-DB] question regarding date format | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-21785@lists.php.net to get a copy of this message | ||
> -----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.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211