【发布时间】:2013-09-15 09:16:53
【问题描述】:
问题
我需要从实际的 datetime 格式字段 date 安全地转换 mySQL 数据库表 MYTABLE 中的日期格式:例如2013-09-10 12:43:03,到它的 unix 时间戳等效值:1378816983,而不会影响数据库中已有的数千篇文章。
我正在使用 PHP、mySql、Drupal。
我的方法
我的步骤
将表字段类型从日期时间更改为时间戳 [DONE]
转换实际内容类型字段:timestamp [DONE]
使用 PHP strtotime() 或 MYSQL 转换 4 个表中的现有文章数据字段:UNIX_TIMESTAMP(date)
我在 PT.3 上需要帮助
A.对pt的算法有一点帮助。 3:
例如
loop over all 4 tables {
- create a new column date2 of type: int (or datetime?)
- copy all dates from date to date2 passing them through strtotime()
- delete column date
- rename column date2 to column date
}
【问题讨论】:
-
你为什么想要它?
标签: php mysql sql unix datetime