You are here: Re: MySQL timezone support - setting from PHP « PHP Programming Language « IT news, forums, messages
Re: MySQL timezone support - setting from PHP

Posted by Rik Wasmus on 10/14/07 19:10

On Sun, 14 Oct 2007 20:54:40 +0200, bill <nobody@spamcop.net> wrote:

> I am using the MySQL date and time functions and they save a lot of my=
=

> time. But the server is located in a time zone 2 hours away. I read =
in =

> the SQL docs how to set the timezone on a per-connection basis, but ho=
w =

> would I do that from PHP ?

Untested:
mysql_query('SET time_zone =3D timezone_name');

Where the MySQL manual states:
timezone values can be given in several formats, none of which are case =
=

sensitive:
1. The value 'SYSTEM' indicates that the time zone should be the same as=
=

the system time zone.
2. The value can be given as a string indicating an offset from UTC, suc=
h =

as '+10:00' or '-6:00'.
3. The value can be given as a named time zone, such as 'Europe/Helsinki=
', =

'US/Eastern', or 'MET'. Named time zones can be used only if the time zo=
ne =

information tables in the mysql database have been created and populated=
..

Ideally, you could use:
mysql_query("SET time_zone =3D '".date_default_timezone_get()."'");

-- =

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

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