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 usedate()
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 formatsstrtotime()
can accept.本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报