我需要使用 PHP (Codeigniter) 将一系列数据插入到 MySQL 表中。
问题:其中一个数据是类似于 06/01/12 01:43 PM
的时间戳。但是,当我将其插入 MySQL 时间戳列时,它会变成 0000-00-00 00:00:00
。如何格式化原始格式以便我可以将其正确插入到时间戳列中?
最佳答案
如果您想通过 PHP 执行转换,这非常简单:
$oldFormat = "06/01/12 01:43 PM";
$newFormat = date("Y-m-d H:i:s", strtotime($oldFormat));
关于php - 将此时间戳插入 MySQL 时间戳列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10890736/