Tass Mark
Tass Mark

Reputation: 337

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!

Upvotes: 0

Views: 509

Answers (1)

K. Uzair
K. Uzair

Reputation: 303

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

Upvotes: 3

Related Questions