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

资源魔 49 0

PHP 提供了函数能够不便的将各类方式的日期转换为工夫戳,该类函数次要是:

strtotime():将任何英文文本的日期工夫形容解析为工夫戳。

mktime():从日期获得工夫戳。

strtotime()

strtotime() 函数用于将英文文本字符串示意的日期转换为工夫戳,为 date() 的反函数,胜利前往工夫戳,不然前往 FALSE 。

语法:

int strtotime ( string time [, int now] )

示例:

<?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(时, 分, 秒, 月, 日, 年)

示例:

<?php
echo mktime(21, 50, 55, 07, 14, 2010);
//输入“1279115455”
?>

更多相干教程请存眷资源魔。

以上就是php中怎样将工夫转换为工夫戳的具体内容,更多请存眷资源魔其它相干文章!

标签: php php教程 php故障解决 php使用问题 时间转换

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