0

I want to convert date format from 'Wed, 27 01 2016 00:00:00 EST' to '2016-01-27'.I got wrong value '1970-01-01'

<?php
date_default_timezone_set("Europe/Helsinki"); 
$var='Wed, 25 11 2015 00:00:00 GMT';
echo $d=date('Y-m-d',strtotime($var));
//DATE_RFC2822
?>
user3386779
  • 6,883
  • 20
  • 66
  • 134

1 Answers1

4

It means the datetime string cannot be recognised automatically. You need to specify format of input:

echo date_create_from_format(
    'D, d m Y H:i:s e',  // <== input format  
    'Wed, 27 01 2016 00:00:00 EST'  // <== your string
)->format("Y-m-d")  // <== output format

More formats here: http://php.net/manual/en/datetime.createfromformat.php

Alex Blex
  • 34,704
  • 7
  • 48
  • 75