2013-07-26 175 views
0

我有以下字符串:2013-03-22获取日期,年份和月份的时间戳

我需要将其转换为UNIX时间戳。

我该如何使用PHP来做到这一点?

+4

http://php.net/manual/en/function.strtotime.php –

+0

我同意@ zdhickman ..你只是通过这个链接:http://php.net/manual/en/function.strtotime .PHP –

回答

5

使用PHP的strtotime函数。

$unixstamp = strtotime("2013-03-22"); 
1

简单:

echo $time = strtotime("2013-03-22"); 
2

随着DateTime class

$dateTime = DateTime::createFromFormat('Y-m-d', '2013-03-22'); 
$dateTime->setTime(0, 0, 0); 
echo $dateTime->getTimestamp(); 
1

使用

strtotime("2013-03-22")

它会将日期sting转换为时间戳值。

相关问题