Home  >  Article  >  Backend Development  >  04 April 2014

04 April 2014

WBOY
WBOYOriginal
2016-06-23 13:59:41787browse

将字符串 

04 April 2014 - 09:00 AM

   转化成时间戳 

strtotime不管用啊

求助~


回复讨论(解决方案)

echo strtotime('04 April 2014 09:00 AM');

怎么可能呢?你是怎么写的?

echo strtotime('04 April 2014 09:00 AM');
得到结果:1396602000 

echo strtotime('04 April 2014 09:00 AM');
得到结果:1396602000 
中间还有一个断线连接着呢 。。。。。

那是你的日期格式不对,删掉就可以了
echo strtotime(str_replace('-', '', '04 April 2014 - 09:00 AM')); //1396573200


echo strtotime('04 April 2014 09:00 AM');
得到结果:1396602000 
中间还有一个断线连接着呢 。。。。。

额,字符串处理问题那。

$str = '04 April 2014 - 09:00 AM';
$str1 = explode("-",$str);
$str2 = join(" ",$str1);
echo strtotime($str2);

那是你的日期格式不对,删掉就可以了
echo strtotime(str_replace('-', '', '04 April 2014 - 09:00 AM')); //1396573200

谢谢~

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn