我有一个日期的格式:Aug 18, 2014 15:30:35.246263000
我想将此格式转换为时间戳,即2014-8-18 15:30:35.
,我不知道时间戳如何处理毫秒。我正在使用PHP和MySql
就像scragar说的,您不能将日期精确地转换为unix时间戳,因为时间戳不支持毫秒。但是,您可以减少毫秒数并使用strtotime,如:
$time = 'Aug 18, 2014 15:30:35.246263000';
$parts = explode('.', $time);
$timestamp = strtotime($parts[0]);
祝你好运!
给你
$date = 'Aug 18, 2014 15:30:35.246263000';
echo date('Y-m-d H:i:s',strtotime(substr($date,0,strpos($date,'.'))));
也可以单行写
echo date('Y-m-d H:i:s',strtotime(substr('Aug 18, 2014 15:30:35.246263000',0,strpos('Aug 18, 2014 15:30:35.246263000','.'))));
希望对你有帮助