PHP中的strtotime()函数
该strtotime()函数将英语文本日期或时间解析为Unix时间戳。成功返回时间戳,否则返回FALSE。在PHP5.1.0之前,此函数在失败时将返回-1。
语法
strtotime(time, now)
参数
时间 -指定时间的字符串进行解析。
现在 -时间戳用于计算返回的值。
返回
该strtotime()函数返回成功时间戳,否则返回FALSE。在PHP5.1.0之前,此函数在失败时将返回-1。
示例
以下是一个例子-
<?php $timestamp = strtotime( "June 20, 2018" ); print date( 'Y-m-d', $timestamp ); ?>
输出结果
2018-06-20
示例
让我们看另一个例子-
<?php
echo(strtotime("now") . "<br>");
echo(strtotime("10 March 2018") . "<br>");
echo(strtotime("+10 hours") . "<br>");
?>输出结果
1539235161 1520640000 1539271161
热门推荐
10 朋友药店开业祝福语简短
11 老师新婚快乐祝福语简短
12 预祝高尔夫的祝福语简短
13 简短有力的结婚祝福语
14 死人新年祝福语简短句
15 元旦祝福语简短有深度
16 送礼祝福语男性生日简短
17 幽默小姐姐祝福语简短
18 英文写结婚祝福语简短