getdate() with GMT?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Thresher
Forum Newbie
Posts: 13
Joined: Sun Apr 01, 2007 3:12 am

getdate() with GMT?

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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.
(#10850)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Typically when I need time in GMT form, I use

Code: Select all

time() - date('Z')
Post Reply