开发者

Formatting a timestamp

开发者 https://www.devze.com 2022-12-10 13:58 出处:网络
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 Time5 Nov 2009Thursday\"?(I think the timestamp in my database i

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

0

精彩评论

暂无评论...
验证码 换一张
取 消