View Full Version : convert datestamp from one to another?
jasonc310771
01-07-2008, 03:42 PM
i have stored the date in the following format...
2008-01-07 15:42:00
it is year,day,month, hour,min,sec
and wish to convert it to the format needed for RSS feeds.
"D, d M Y H:i:s GMT"
how can i do this please.
thanks
This should work (untested!):
$original_date = "2008-01-07 15:42:00";
$reformatted_date = date("D, d M Y H:i:s \G\M\T", strtotime($original_date));
Might come out with 7th Jan rather than 1st July though ...
jasonc310771
01-07-2008, 04:09 PM
i have PHP version 4.3.11
is there another way?
Both date() and strtotime() are present in all versions of PHP4 :)
Opps! Just noticed you'd replied to the original version of my message! Lol! Yep, the edited one should work - but watch the d/m thing m/d thing
CFMaBiSmAd
01-07-2008, 04:22 PM
Where do you have it stored in that format?
Edit: And do you truely want that to be - year,day,month or do you want it to be year,month,day?
Indeed, if it's in a MySQL database you can use the DATE_FORMAT function.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.