![](https://img.php.cn/upload/article/000/000/051/5ee0867b6241f985.jpg)
php中日期转换为时间戳:
日期转换为时间戳
PHP 提供了函数可以方便的将各种形式的日期转换为时间戳,该类函数主要是:
strtotime():将任何英文文本的日期时间描述解析为时间戳。mktime():从日期取得时间戳。
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 />"; //输出明天此时的时间戳 ?>
推荐教程: 《php教程》
以上就是php中日期怎么转换为时间戳的详细内容,更多请关注php中文网其它相关文章!
![php中文网最新课程二维码](/static/images/article_wechat2021.jpg?1111)
声明:本文原创发布php中文网,转载请注明出处,感谢您的尊重!如有疑问,请联系admin@php.cn处理
- 上一篇:php字符串怎么转换成json
- 下一篇:php怎么把字符编码转utf8
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论