List:General Discussion« Previous MessageNext Message »
From:Jerry Schwartz Date:June 21 2011 12:59pm
Subject:RE: SELECT records less than 15 minutes old
View as plain text  
<snip>

>-----Original Message-----
>From: sono-io@stripped [mailto:sono-io@stripped]
>Sent: Monday, June 20, 2011 6:01 PM
>To: mysql@stripped
>Cc: wharms@stripped; Jerry Schwartz
>Subject: Re: SELECT records less than 15 minutes old
>
>On Jun 20, 2011, at 10:11 AM, Jerry Schwartz wrote:
>
>>> You should use UTC time zone or you will run into trouble with DST.
>>>
>> [JS] If you do that, you can't use an automatic timestamp field. You have 
>> to
>> set the field yourself.
>
>	Thanks Walter and Jerry.
>
>	Is there a way to get NOW() to use UTC instead of the server timezone?
>(The server is not mine, so I can't change the my.cnf.)  Here's my statement:
>
>SELECT * FROM `log` WHERE `id` = $_id AND ( `time_stamp` >= DATE_SUB(NOW(),
>INTERVAL 30 MINUTE) )
>

>	Earlier in my PHP script I've used date_default_timezone_set, but that
>doesn't affect the MySQL statement.
>
>------
>
>Possible Solution
>
>I tried: SET time_zone = 'UTC';
>but MySQL complained with: #1298 - Unknown or incorrect time zone: 'UTC'
>
>I then tried:
>SET time_zone = '-0:00';
>and that seems to have worked.  Is this the correct way to do it?
>

[JS] I believe that is the only way to do it.

The reason you can't use time zone names is that the time zone tables in MySQL 
have not been loaded.

Regards,

Jerry Schwartz
Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341
E-mail: jerry@stripped
Web site: www.the-infoshop.com






Thread
SELECT records less than 15 minutes oldsono-io19 Jun
  • Re: SELECT records less than 15 minutes oldClaudio Nanni19 Jun
    • Re: SELECT records less than 15 minutes oldsono-io19 Jun
      • Re: SELECT records less than 15 minutes oldwalter harms20 Jun
        • RE: SELECT records less than 15 minutes oldJerry Schwartz20 Jun
          • Re: SELECT records less than 15 minutes oldsono-io21 Jun
            • Re: SELECT records less than 15 minutes oldwalter harms21 Jun
            • RE: SELECT records less than 15 minutes oldJerry Schwartz21 Jun