get UTC time in PHP

Robin Michael Poothurai picture Robin Michael Poothurai · Dec 28, 2011 · Viewed 252.5k times · Source

How can I get UTC/GMT +/- time stamp using PHP's date() function? For example, if I try

date("Y-m-d H:i:s", time()); 

I will get Unix time stamp; but I need to get UTC/GMT time stamp with string GMT/UTC+/-0400 or GMT/UTC+/-1000 based on local timings.

Answer

nikc.org picture nikc.org · Dec 28, 2011

Using gmdate will always return a GMT date. Syntax is same as for date.