问题
我需要安全地将 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
}