当前位置: 动力学知识库 > 问答 > 编程问答 >

Converting a string timestamp to a MySQL timestamp with PHP

问题描述:

Possible Duplicate:

Converting string to MySQL timestamp format in php

Given a date in the following format, how would I convert it into a MySQL TIMESTAMP format in PHP?

Tue, 06 Dec 2011 16:47:11 +0000

I found a similar question, but am having some difficulty in converting it into what I need.

网友答案:

date('Y-m-d H:i:s',strtotime('Tue, 06 Dec 2011 16:47:11 +0000'))

that's 'canonical' form, but MySQL will also accept

date('YmdHis',strtotime('Tue, 06 Dec 2011 16:47:11 +0000'))

(more details about that format: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-literals.html )

分享给朋友:
您可能感兴趣的文章:
随机阅读: