Converting a datetime back to the original format

蹲街弑〆低调 提交于 2019-12-13 08:21:57

问题


I used this code

$new_date = date('Y-m-d H:i:s', timetostr($orig_date));

to convert this input Wed Jun 2 2010 to a datetime output 2010-06-02 00:00:00

When I read it from the database, how do I convert it back to the original format of Wed Jun 2 2010?


回答1:


You can use the function strftime() (see php.net manual: strftime() for further information and all parameters) with specified parameters to convert the timestamp back to a human-readable format.

You can use the function this way strftime("%a %b %d %Y") where %a stands for the shortened name of the weekday, %b for the shortened name of the month, %d for the day of the month and %Y for the YYYY representation of the specified year.



来源:https://stackoverflow.com/questions/3040419/converting-a-datetime-back-to-the-original-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!