php中日期怎么转换为时间戳-PHP问题

资源魔 34 0

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教程 php故障解决 php使用问题

抱歉,评论功能暂时关闭!