From: John Daisley [mailto:[email protected]] Sent: Friday, June 03, 2011 6:09 AM To: Rocio Gomez Escribano Cc: [email protected] Subject: Re: timezone
now() returns the current system time which doesn't really have a great deal to do with time zones. [JS] I think that statement is confusing – at least, it is to me. Unless you specify otherwise, NOW() returns the current system time in the system’s time zone. Your comment could be interpreted to mean that it doesn’t use any time zone: i.e., that it returns the UTC. Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 E-mail: [email protected] Web site: www.the-infoshop.com <http://www.the-infoshop.com/> You can check what the current time zone is set to with the following command show variables like 'time_zone'; but that is likely to return the value 'SYSTEM' which means it takes the value from the host operating system ( usually set in /etc/timezone ). You can set the time_zone variable either globally or per session to an offset of UTC as follows SET time_zone='+00:00:00'; SET GLOBAL time_zone='+00:00:00'; Or you can specify a 'default_time_zone' in your my.cnf/my.ini options file. You can also set the time_zone variables to a named offset which will then take account of daylight savings times but to do this you must first load the mysql time zone tables. I strongly suggest you read the manual section relating to time zone support which you can find here http://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html On 3 June 2011 10:27, Rocio Gomez Escribano <[email protected]> wrote: I’m afraid I don’’t understand you: mysql> select count(*) from mysql.time_zone_name; +----------+ | count(*) | +----------+ | 0 | +----------+ 1 row in set (0.00 sec) But, when I execute: mysql> select now(); +---------------------+ | now() | +---------------------+ | 2011-06-03 11:28:00 | +---------------------+ 1 row in set (0.00 sec) That’s correct, in Spain it’s that time. So, mysql is using the timezone correctly, isn’t it? Thanks! Rocío Gómez Escribano <mailto:[email protected]> [email protected] Descripción: cid:[email protected] Polígono Campollano C/F, nº21T 02007 Albacete (España) Tlf:967-504-513 Fax: 967-504-513 <http://www.ingenia-soluciones.com> www.ingenia-soluciones.com De: John Daisley [mailto:[email protected]] Enviado el: viernes, 03 de junio de 2011 11:18 Para: Rocio Gomez Escribano CC: [email protected] Asunto: Re: timezone Have you populated the timezone tables? Run this query if you are not sure. SELECT COUNT(*) FROM mysql.time_zone_name; If it returns 0 then you need to populate the them as per the instructions here http://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html Default timezone in mysql is set at server startup to SYSTEM, which means so long as your system clock is correct the MySQL server should be correct. On 3 June 2011 09:55, Rocio Gomez Escribano <[email protected]> wrote: Hello! I’m having trouble with timezones. I’m in Spain, we have 2 different timezone now we are in GMT+2, in winter, this is the GMT+1. I’m looking for an instruction which give me the current timezone, but I cant find it! Do you know how can I now it? Thanks! Rocío Gómez Escribano [email protected] <mailto:[email protected]> ¡Error! Nombre de archivo no especificado. Polígono Campollano C/F, nº21T 02007 Albacete (España) Tlf:967-504-513 Fax: 967-504-513 <http://www.ingenia-soluciones.com> www.ingenia-soluciones.com -- John Daisley Certified MySQL 5 Database Administrator Certified MySQL 5 Developer Cognos BI Developer Telephone: +44 (0)7918 621621 Email: [email protected] -- John Daisley Butterfly Information Systems Microsoft SQL Server Database Administrator Certified MySQL 5 Database Administrator & Developer Cognos BI Developer \ Administrator Available for short & long term contracts Telephone: +44 (0)7918 621621 Email: [email protected]
