You are here: Re: date() function - problem changing timezome « All PHP « IT news, forums, messages
Re: date() function - problem changing timezome

Posted by Rik on 09/28/55 11:49

shannonwhitty@hotmail.com wrote:
> Please help,
>
> I am running a database on a free server in another country and the
> timezone is obviously different. All I want to do is add 15 hours to
> the timezome before updating the database (or on update would be
> fine!!!)
>
> I can output the current timestamp perfectly as:
>
> echo date("Y-m-d H:i:s");
>
> 2006-06-05 07:20:57
>
> But when I try to use the Z function I can't get it to work... There
> is very little help or working demos on this anywhere on the
> internet...
>
> echo date("Y-m-d H:i:s", date("Z +54000"));

You cannot use it like that
date("Z +54000") is not calculated, it's just a string "you_timezone
+54000);
PHP will cast it to a number, doesn't recognize the space after the number
representing the timezone, so only casts the timezone to a number.(-43200
through 43200). And that's not a date, just the offset of second of the
timezone.

> 1969-12-31 13:00:00

I suspect if you echo date("Z"), we'll see that your timezone is -39600?

What happens:
Date creates a date from a timestamp, the number of seconds since 01-01-1970
00:00:00.
If your timezone is -39600, that's negative, so 01-01-1970 minus 39600
seconds is 1969-12-31 13:00:00

You could do several things. One like the solution you're trying to perform:
date("Y-m-d H:i:s", time() + 54000);

Grtz,
--
Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация