绝对时间戳 [英] Absolute Timestamp

查看:305
本文介绍了绝对时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我刚刚开始使用绝对模板来了解时间戳。在其中一个示例中,它说 $ date1 = strtotime('2015-06-01'); 将输出 Mon 08/01/2015 ,但我只得到一个数字 1433113200 。我在做什么错了。

Hi I've just started learning about timestamp with an absolute template. In one of the examples it says $date1 = strtotime('2015-06-01'); will output Mon 08/01/2015 but I only get a number 1433113200. What am I doing wrong.

$date1 = strtotime('2015-06-01');
echo $date1;


推荐答案

像这样尝试,得到的数字是unix您日期的时间戳。您需要重新格式化。

Try like this, the number you get is the unix time stamp of your date. You need to reformat it.

$date1 = date('D d/m/Y h:i:s A',strtotime('2015-06-01'));
echo $date1;

以下是您可以使用的格式列表(

Here's a list of format that you can use (Source)

Day of Month
____________
d   | Numeric, with leading zeros   01–31
j   | Numeric, without leading zeros    1–31
S   | The English suffix for the day of the month   st, nd or th in the 1st, 2nd or 15th.

Weekday
_______
l   | Full name  (lowercase 'L')    Sunday – Saturday
D   | Three letter name Mon – Sun

Month
______
m   | Numeric, with leading zeros   01–12
n   | Numeric, without leading zeros    1–12
F   | Textual full  January – December
M   | Textual three letters Jan - Dec

Year
____
Y   | Numeric, 4 digits Eg., 1999, 2003
y   | Numeric, 2 digits Eg., 99, 03

Time
____
a   | Lowercase am, pm
A   | Uppercase AM, PM
g   | Hour, 12-hour, without leading zeros  1–12
h   | Hour, 12-hour, with leading zeros 01–12
G   | Hour, 24-hour, without leading zeros  0-23
H   | Hour, 24-hour, with leading zeros 00-23
i   | Minutes, with leading zeros   00-59
s   | Seconds, with leading zeros   00-59
T   | Timezone abbreviation Eg., EST, MDT ...
Full Date/Time
c   | ISO 8601  2004-02-12T15:19:21+00:00
r   | RFC 2822  Thu, 21 Dec 2000 16:01:07 +0200

这篇关于绝对时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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