mysql更新datetime,将Mysql时间戳记中的值更新为datetime值。

I need to Update values in Mysql timestamp filed to a datetime value. for example for a field join date, currently the field type is int(11) and the values are in timestamp. I need change this fields as date time filed or create a new datetime filed , then populate the field with datetime value of old timestamp value.

It can do with php code with looping . If there is any mysql query for that it will be interesting.

Many thanks for all of your helps,

Happy coding

解决方案

Alternatively, alter the table by adding another column of field DateTime. Name this column as DateTimeField or whatever you want. After the table has been altered, execute this query

UPDATE tableName

SET DateTimeField = FROM_UNIXTIME(yourOldTimstampField)

你可能感兴趣的:(mysql更新datetime)