...

View Full Version : convert datestamp from one to another?



jasonc310771
01-07-2008, 04: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

mlse
01-07-2008, 05:02 PM
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, 05:09 PM
i have PHP version 4.3.11

is there another way?

mlse
01-07-2008, 05:11 PM
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, 05: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?

mlse
01-07-2008, 05:26 PM
Indeed, if it's in a MySQL database you can use the DATE_FORMAT function.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum