Page 1 of 1

getdate() with GMT?

Posted: Mon Apr 02, 2007 4:25 pm
by Thresher
Is there a function like getdate() that returns the time tuple in GMT instead of local time? Just as date() has gmdate() and mktime() has gmmktime(), I was hoping to find a gmgetdate() but did not.

The clearest distillation of the problem is to execute print_r(getdate(0)). Assuming your local time is not GMT, you will see that you do not get midnight at January 1, 1970. You get your local time translation of midnight on January 1, 1970 GMT.

Even if there is not a single function like gmgetdate() is there a way to get the same functionality?

Thanks.

Posted: Mon Apr 02, 2007 5:21 pm
by Christopher
I think maybe something like the following would work:

Code: Select all

getdate( gmmktime() )
But that may just give the same dates as you mentioned. feyd recently posted a massive date class -- thereby anointing himself Chronos() - Lord of Date Functions (usually followed by a thunderclap ;)). Perhaps he can help.

Posted: Mon Apr 02, 2007 9:21 pm
by feyd
Typically when I need time in GMT form, I use

Code: Select all

time() - date('Z')