将PHP中的特定时间格式转换为MYSQL日期时间类型


Convert specific time format to in PHP to MYSQL datetime type

我需要一些关于时间格式化的帮助。

我从文件中得到的输入是(例如): 周三 6 月 28 日 19:12:55 CEST 2015, 所以: 日期名称 月(文本) 天 小时:分钟:第二时区 年份。

我想将其转换为Mysql日期时间格式,以便能够存储在数据库中。

格式为(例如):2016-03-06 12:09:44,即年-月(数字)-天小时-分钟-秒

谢谢!

您可以使用 php 的日期函数。

echo date("Y-m-d h:i:s",strtotime($yourDateTimeVariable));

有关更多帮助,请参阅 PHP 手册以获取日期。

http://php.net/manual/en/function.date.php

希望对你有帮助