Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我传递30/07/2013 23:51给以下函数:
30/07/2013 23:51
$date = date('Y-m-d H:i:s', strtotime(str_replace('-', '/', $data)));
我得到的是:1970-01-01 01:00:00
1970-01-01 01:00:00
我需要做的是将给定日期转换为 mysql 字段的“日期时间”(或更好的“时间戳”)格式
日期以意大利语格式给出。
不幸的是,您必须手动完成。此功能将起作用:
function date_cast($data) { $data = explode(' ', $data); $time = $data[1]; $date = explode('/', $data[0]); return $date[1]."/".$date[0]."/".$date[2]." ".$time; }
然后你可以打电话:
$date = date_cast('30/07/2013 23:51');