2017-01-07 00:00:00少芬 网页程序设计
PHP 提供了函数可以方便的将各种形式的日期转换为时间戳,该类函数有哪些?下面yjbys小编为大家分享php时间戳的转换函数,欢迎阅读!
strtotime():将任何英文文本的日期时间描述解析为时间戳。
mktime():从日期取得时间戳。
strtotime()
strtotime() 函数用于将英文文本字符串表示的日期转换为时间戳,为 date() 的反函数,成功返回时间戳,否则返回 FALSE 。语法:
int strtotime ( string time [, int now] )
参数 time 为被解析的字符串,是根据 GNU 日期输入格式表示的日期。
例子:
<?php
echo strtotime("2009-10-21 16:00:10");//输出 1256112010
echo strtotime("10 September 2008");//输出 1220976000
echo strtotime("+1 day"), "<br />";//输出明天此时的时间戳
?>
mktime()
mktime() 函数用于从日期取得时间戳,成功返回时间戳,否则返回 FALSE 。语法:
int mktime(时, 分, 秒, 月, 日, 年)
..........
阅读全文[网页程序设计]热门推荐
861
人