Convert date format to mysql timestamp

I have several dates that are returned as the following line:

Fri, 13 Aug 2010 01:48:47 -0400 (EDT)

I would like to analyze this and turn it into a date and time stamp, like this:

2010-08-13 01:48:47

Any help would be awesome ... thanks!

+3
source share
1 answer

It looks like you DO NOT want the time zone to be converted.

You can do this using date()and strtotime()acts as follows:

$date = "Fri, 13 Aug 2010 01:48:47 -0400 (EDT)";
$date = explode('-',$date);
echo date("Y-m-d H:i:s", strtotime($date[0])); //does not use TimeZone info

It is output:

2010-08-13 01:48:47

+9
source

Source: https://habr.com/ru/post/1763254/


All Articles