Reply to Re: summer time issue in mysql

Your name:

Reply:


Posted by ZeldorBlat on 09/26/06 15:47

ojorus wrote:
> Hi!
> A simple question maybe...
>
> I have a datetime column in a table, and want to automaticly insert local
> (Norwegian) time into the column. (I use PHP 5) I can not use NOW() since
> the mysql server is set up with a different time zone. So now i use
> UTC_TIMESTAMP() + INTERVAL 2 HOUR, which give me the right time now. BUT a
> problem will occur some time in october, when we end summer time, and Norway
> will go back to UTC + 0100.
> Of course I could manually go into my PHP code and change the query to ...
> UTC_TIMESTAMP() + INTERVAL 1 HOUR ..., but I was hoping there was some
> easier way to to this. (I don't want to change my code twice a year...).
>
> One solution is of course to tell my PHP code when summer time starts and
> ends for the next say ten years, and then vary the INTERVAL number from 1 to
> 2 or the other way. But still I was hoping there was some easier ways...
>
> Any suggestions?
>
> greetings
> ojorus

In PHP, call date_default_timezone_set() with the appropriate timezone
setting. Then use date() to format the UTC timestamp you get from
MySQL. No adding or deleting hours, no summer time, everything will
just take care of itself.

[Back to original 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

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