繁体   English   中英

将日期转换为UNIX时间戳

[英]Convert Date to UNIX timestamp

我的日期格式是Jun 26, '12
strtotime()转换正确的日期字符串,此字符串将导致空白输出。 这可以解决,但我只能想到丑陋的做法。

有关将此日期格式转换为UNIX时间戳的任何想法都很优雅吗?

这个strtotime('Jun 26,12');怎么样strtotime('Jun 26,12');

我使用DateTime::createFromFormat对我来说效果很好..更多信息在这里

嗯, s/'/20/g' 其次是strtotime()

也许是这样的?

$string = 'April 26,\'12';
echo strtotime(preg_replace('/(\w+) (\d+),\'(\d+)/i', '$2 $1 20$3', $string));

基于php.net的例子

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM