将Mysql时间戳记中的值更新为datetime值。 [英] Update values in Mysql timestamp to a datetime value.

查看:897
本文介绍了将Mysql时间戳记中的值更新为datetime值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将Mysql时间戳记中的值更新为datetime值。例如对于字段连接日期,当前的字段类型为int(11),值为时间戳。我需要更改这个字段作为日期时间提交或创建一个新的datetime字段,然后填充字段与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.

它可以用循环的PHP代码。如果有任何mysql查询,那将是有趣的。

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

推荐答案

或者,通过添加另一列字段 DateTime 来更改表。将此列命名为 DateTimeField 或任何您想要的。表更改后,执行此查询

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值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆