Formatting a timestamp
The MySQL variable below formats as "2009-11-05 22:5开发者_开发问答1:26" when it is printed. How could I format it to "22:51 New York Time 5 Nov 2009 Thursday"? (I think the timestamp in my database is United States eastern time zone.) I am using PHP.
createddatetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP
date_default_timezone_set('America/New_York');
$timestamp = "2009-11-05 22:51:26";
echo date('H:i e j M Y l', strtotime($timestamp)); //22:51 America/New_York 5 Nov 2009 Thursday
See date()
for a list of format parameters. I matched your requested output pretty closely but you may want to tweak it
strtotime()
- Parse about any English textual datetime description into a Unix timestamp
精彩评论