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 生日广州男生祝福语简短