开发者

How to convert timestamp format to 2011-05-10T06:58:00?

I have a column in my drupal database called "field_concert_published_value" which is storing the values of the concert publishing (it is a cck开发者_如何学Python field)

I have old records from previous system and there is stored this value as classical timestamp.

I know how to INSERT INTO ... however the format of the date time cck field is unusual. I mean e.g. 2011-05-10T06:58:00 . The letter T between the date and time, so I can not use FROM_UNIXTIME function to convert from my old records to this yyyy-mm-ddThh:ii:ss.

Any advice how to convert my old records in timestamp format to the new one which date time filed is using?

Thanks.

P.S. I need this to be done using SQL statement (MySql)


Have you tried STR_TO_DATE, FROM_UNIXTIMESTAMP and TIME_FORMAT?

SELECT DATE_FORMAT( DATE( FROM_UNIXTIME( `timestamp` ) ), '%Y-%m-%dT%H.%i.%s');

This page has a good explanation of the date tokens: MySQL Date Time Formatting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜