php中日期转换为时间戳:
日期转换为时间戳
PHP 提供了函数可以方便的将各种形式的日期转换为时间戳,该类函数主要是:
strtotime():将任何英文文本的日期时间描述解析为时间戳。mktime():从日期取得时间戳。
strtotime() 函数用于将英文文本字符串表示的日期转换为时间戳,为 date() 的反函数,成功返回时间戳,否则返回 FALSE 。
立即学习“PHP免费学习笔记(深入)”;
语法:
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 />"; //输出明天此时的时间戳 ?>
推荐教程: 《php教程》
以上就是php中日期怎么转换为时间戳的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号