Suppose I got the s开发者_如何学JAVAtring 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));
?>
DEMO
$date="01:07:13 May 07, 2011 PDT";
$query = "UPDATE table SET datefield = str_to_date('$date','%M %d,%Y PDT')
WHERE ...."
See: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date
精彩评论