Convert specific time format to in PHP to MYSQL datetime type

I need some help about time formatting.

The input I get from a file is (for example): Wed Jun 28 19:12:55 CEST 2015, so: name of the day Month(text) Day Hour:minute:second Timezone Year.

I would like to convert it to Mysql datetime format, to be able to store in a database.

The format is (for example): 2016-03-06 12:09:44, which is Year-Month (number)-Day Hour-Minute-Second

Thank you!


You can use date function of php.

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

for more help see php manual for date.

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

Hope it helps

链接地址: http://www.djcxy.com/p/58984.html

上一篇: 流星如何调用客户端js函数,仅用于添加到Collection中的项目

下一篇: 将特定时间格式转换为PHP到MYSQL日期时间类型