Formatting a timestamp

前端 未结 1 590
眼角桃花
眼角桃花 2021-01-24 09:09

The MySQL variable below formats as \"2009-11-05 22:51:26\" when it is printed. How could I format it to \"22:51 New York Time 5 Nov 2009 Thursday\"? (I think the timestamp

相关标签:
1条回答
  • 2021-01-24 09:54
    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 讨论(0)
提交回复
热议问题