| Welcome to WebmasterWorld Guest from 188.8.131.52 |
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
|Accredited PayPal World Seller|
|How to format date|
from YYYY-MM-DD to DD/MM/YYY and vice versa
| 7:02 am on Oct 11, 2008 (gmt 0)|
How do I format date that will work on both PHP 4 and 5. I want to format date from from YYYY-MM-DD to DD/MM/YYY and vice versa. Is there a built-in function?
| 7:26 am on Oct 11, 2008 (gmt 0)|
apply strtotime() to your date in this format YYYY-MM-DD and then send the strtotime() generated unixTimestamp to date() with your new format
| 9:58 am on Oct 11, 2008 (gmt 0)|
| 10:02 am on Oct 11, 2008 (gmt 0)|
On a related note when I run the following code it is treating "05" as month when in fact it's a day...any idea how to fix it
$dt = "05/01/2008";
print date("Y-m-d", strtotime($dt));
OUTPUT is 2008-05-01
The date in $dt is in format d/m/Y
| 10:08 am on Oct 11, 2008 (gmt 0)|
The first User Contributed Note from top addresses that issue.
[edited by: Anyango at 10:09 am (utc) on Oct. 11, 2008]
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
© Webmaster World 1996-2014 all rights reserved