2012-11-27 56 views
0

我有一个日期字符串,我想在数字转换。该字符串看起来像php字符串到时间问题

Dienstag, 30. Oktober 2012 

和代码我一直在尝试使用每次1970.01.01

回答

1

strtotime需要串在英语

date('Y.m.d' , strtotime($str[4])); 

回报。看看可能date/time formats

+0

感谢您的意见。我可以使用setlocale(LC_TIME,“de_DE”)吗?获取我的字符串转换 – fefe

0

使用strtotime()将日期转换为时间戳

$ ts = strtotime('2007年12月21日'); echo date('Y-m-d',$ ts);

0
<?php 
setlocale(LC_ALL, 'fr_FR'); 
$str= 'Dienstag, 30. Oktober 2012'; 

echo date('Y.m.d' , strtotime($str[4])); 
?> 
+0

为什么在日期是德语时使用法语区域设置? – Bojangles

+0

这不会起作用 – fefe

+0

<?php setlocale(LC_ALL,'de_DE'); $ str ='Dienstag,30十月2012'; echo date('Y.m.d',strtotime($ str [4])); ?> //2012.11.28//请检查这个 – Arun