-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
  • 20,667
  • 5
  • 43
  • 53
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
  • 20,667
  • 5
  • 43
  • 53
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
  • 132
  • 1
  • 7