0

I have timestamp stored in MySQL in following format:

$if_modified_since = date('Y-m-d H:i:s');

The timestamp is saved using server's default timezone which in my case is EST. I need to send a CURL request with if-modified-since header.

curl_setopt($ch, CURLOPT_HTTPHEADER, array("If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T',$if_modified_since)));

What will be the most optimal way for me to convert time in EST to GMT? Also is there a way to make it totally generic by checking the server timezone (instead of just hard-coding in EST)?

Ahmad
  • 474
  • 1
  • 4
  • 19

1 Answers1

0

This worked for me:

$d = DateTime::createFromFormat('Y-m-d H:i:s', $if_modified_since, new DateTimeZone(ini_get('date.timezone'))); 
curl_setopt($curl, CURLOPT_HTTPHEADER, array("If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T',$d->getTimestamp())));
Ahmad
  • 474
  • 1
  • 4
  • 19