| Welcome to WebmasterWorld Guest from 22.214.171.124 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Pubcon Platinum Sponsor 2014|
|How to format date|
from YYYY-MM-DD to DD/MM/YYY and vice versa
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?
apply strtotime() to your date in this format YYYY-MM-DD and then send the strtotime() generated unixTimestamp to date() with your new format
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
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.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved