doufu1950 2011-08-04 05:20
浏览 27
已采纳

将mysql时间戳转换为php用户友好版本

i have 2011-08-03 21:56:41 coming from a MySQL timestamp and I would like to convert it to Wednesday August 3rd, 2011 using PHP (Not MySQL). How can this be done?

  • 写回答

1条回答 默认 最新

  • duan19780629 2011-08-04 05:24
    关注

    Use strtotime() to convert your date/time string to a Unix timestamp so you can use date() to format the value of that timestamp any way you want.

    $stamp = '2011-08-03 21:56:41';
    echo date('l F jS, Y', strtotime($stamp));
    
    // output: Wednesday August 3rd, 2011
    

    The reference at the date() manual page is extremely useful. I still reference it all the time for the list of special format characters.

    The strtotime() function sort of seems like magic at first. For future reference, here's the supported date/time documentation on what input formats strtotime() can accept.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面