I need to get the current GMT timestamp from PHP in the following format.
2012-03-05T16:53:13Z
Following is the method I used but it seems not accurate?
str_replace('+00:00', '.000Z', gmdate('c', strtotime("now")));
Date("c") is close to what you need but I'm not sure about your replacement.
As I see it you want the first 19 characters of date("c") and then a "Z".
date_default_timezone_set("UTC");
echo substr(date("c", time()), 0, 19). "Z";
//2018-12-13T05:45:45Z