首页 > PHP教程 > PHP常用函数手册 > PHP Date/Time相关函数

PHP strtotime() 函数

 函数原型

/**

 * 将英文文本的日期时间描述解析为 Unix 时间戳

 * @link http://php.net/manual/en/function.strtotime.php

 * @param string $time  日期/时间字符串

 * @param int $now [optional]   可选参数,用来计算返回值的时间戳

 * @return int   成功返回时间戳,失败返回 FALSE。在 PHP 5.1.0 之前本函数在失败时返回 -1。

 * @since 4.0

 * @since 5.0

 */

function strtotime ($time, $now = null) {}

 

函数示例

<?php

echo strtotime("now");

echo time();

echo strtotime("26 October 2016") ."</br>";

echo strtotime("2016-10-26 06:06:01");

echo strtotime("+5 hours") ;

echo strtotime("+6 week");

echo strtotime("+1 week 3 days 7 hours 5 seconds");

echo strtotime("next Monday") ;

echo strtotime("last Sunday") ;

?>

关闭
感谢您的支持,我会继续努力!
扫码打赏,建议金额1-10元


提醒:打赏金额将直接进入对方账号,无法退款,请您谨慎操作。