本文介绍了PHP-格式日期/时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我得到的日期字符串看起来像"PDT 2011年5月7日01:07:13",如何将其格式化为"2007-07-20 17:20:07"这样的格式(数据类型-时间戳),这样我就可以将其插入MySQL
Suppose I got the string of date look like "01:07:13 May 07, 2011 PDT", how can I format it to the format like "2007-07-20 17:20:07" (data type - timestamp) so that I can insert it to MySQL
推荐答案
<?php
$date="01:07:13 May 07, 2011 PDT";
echo date('Y-m-d h:i:s',strtotime($date));
?>
这篇关于PHP-格式日期/时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!