By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,769 Members | 1,382 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,769 IT Pros & Developers. It's quick & easy.

making gmdate output equal date output

P: n/a
gmdate('F j, Y, g:i a',0) returns January 1, 1970, 12:00 am.
How do I add to the second parameter of the date function to make it
always return that same date, regardless of the time zone?
Intuitively, it seems like date('F j, Y, g:i a',0 - date('Z')) should
do it, but on my system, that's an hour off.

Here's some sample code:

<?
echo gmdate('F j, Y, g:i a',0).'<br />';
echo date('F j, Y, g:i a',0 - date('Z')).'<br />';
echo date('F j, Y, g:i a',0 - date('Z') + 60*60);
?>

And here's the output on my system:

January 1, 1970, 12:00 am
December 31, 1969, 11:00 pm
January 1, 1970, 12:00 am

Will the last echo always return the same thing as the first echo,
regardless of the time zone? If so, why? It seems that the second one
is the one that should do it - not the first one.

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

yawnmoth wrote:
gmdate('F j, Y, g:i a',0) returns January 1, 1970, 12:00 am.
How do I add to the second parameter of the date function to make it
always return that same date, regardless of the time zone?
<snip>


Never mind - I figured the answer out, myself. I need to correct for
daylight savings time.

date('F j, Y, g:i a',0 - date('Z') + 60*60*date('I')) does it.

Jul 17 '05 #2

P: n/a
yawnmoth wrote:
Will the last echo always return the same thing as the first echo,
regardless of the time zone? If so, why? It seems that the second one
is the one that should do it - not the first one.


erm... daylight savings perhaps?
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.