Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert date format to mysql time stamp

I have some dates that are returned as the following string:

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

I'd like to parse this and turn it into a datetime stamp, so like this:

2010-08-13 01:48:47

Any help would be awesome... thank you!

like image 208
dzm Avatar asked Dec 07 '25 09:12

dzm


1 Answers

It looks like you do NOT want the timezone to be converted.

You can do it using date() and strtotime() functions like this:

$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

This outputs:

2010-08-13 01:48:47

like image 136
shamittomar Avatar answered Dec 08 '25 23:12

shamittomar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!