-1

How can i convert a datetime in the format yyyy-mm-dd H:i:s to yyyy-mm-ddT00:00:00Z (UTC). As my default timezone is not in UTC but i can set that for this conversion. for Amazon CloudSearch supporting format.

Narendrasingh Sisodia
  • 21,247
  • 6
  • 47
  • 54
Sanjay
  • 761
  • 14
  • 25

2 Answers2

2

Simply try using gmdate function as

$timestamp = gmdate('Y-m-d\TH:i:s\Z P');
echo $timestamp;
Narendrasingh Sisodia
  • 21,247
  • 6
  • 47
  • 54
1

Try this

$old_format = "2015-06-07 11:05:10";

$new_format = date("Y-m-d\TH:i:s\Z", strtotime($old_format));

echo $new_format;

Kamlesh Suthar
  • 182
  • 2
  • 8