0

I have a function to convert EDT to system time,

function edttogmt($date){

  $date = str_replace('$','', $date);
  $date = str_replace('EDT','', $date);
  $date = date('Y-m-d H:i:s',strtotime($date));
  return $date;
 }

And my date is like $date = '$07/23/2015 12:38:23 PM EDT'; Is it possible to convert this to my server time.The above function creates wrong

Shijin TR
  • 7,516
  • 10
  • 55
  • 122

1 Answers1

0

You can exactly describe the input format to receive DateTime object

$date = DateTime::createFromFormat('$m/d/Y h:i:s A e', '$07/23/2015 12:38:23 PM EDT');
echo $date->format('Y-m-d H:i:s'); // 2015-07-23 12:38:23
splash58
  • 26,043
  • 3
  • 22
  • 34