将日期格式化为可读格式 [英] Formatting date to human readable format

查看:86
本文介绍了将日期格式化为可读格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说,在我的mysql数据库中,我有一个时间戳记2013-09-30 01:16:06,可以说这个变量为$ts.

Lets say in my mysql database I have a timestamp 2013-09-30 01:16:06 and lets say this variable is $ts.

如何输出此图像以使其更像September 30th, 2013?

推荐答案

$timestamp = "2013-09-30 01:16:06";
echo date("F jS, Y", strtotime($timestamp)); //September 30th, 2013

请注意使用S来获取当天的英语序数后缀.
由于您已经在使用strtotime,如果需要在当前时间上使用人类可读的数据,则可以像在 now " >

Note the use of S to get the english ordinal suffix for the day.
Since you're already using strtotime if you need a human readable data for the current time you can just use the keyword "now" as in strtotime("now")

相关来源

  • Date
  • strtotime

这篇关于将日期格式化为可读格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆