I want to select the "currently available" records based on the attributes in the tables. I think it should be easy, but of course, I am not seeing it. I am hoping that by asking here my head will be rooted that maybe I can answer my question!
I have 2 tables:
table_1 id time_zone_name (for example, "US / Eastern") Table_2 Tab 1_day day_off_wek (1 = Monday, 7 = Saturday) Given that the current GMT timestamp is, say "2012-07-08 13:35 GMT", I should be able to pick a record from table_1 where table_2.day_of_week A match is followed by the adjustment for timezone . The MySQL function CONVERT_TZ looks promising!
CONVERT_TZ ('2004-01-01 12:00:00', 'GMT', 'MET')
CONVERT_TZ ('2004-01-01 12:00:00' , '+00: 00', '+ 10:00');
I could try doing this:
SELECT ID to join table_1 table_2 ON (Table_1.id = table_2.table_1_id) < WHERE DAYOFWEEK (CONVERT_TZ (UTC_TIMESTAMP, 'GMT', table_1.time_zone_name)) = table_2.day_of_week
But the CONVERT_TZ function does not accept MySQL installed on my host "US / Eastern "Field names like". According to MySql Doctor:
To use named time zones such as 'MET' or 'Europe / Moscow', the time zone table should be properly set up.
Obviously they are not set up properly.
Is there a better way to go about this? Any suggestions would be most appreciated.
If you are using the lookup table to get the difference, then make sure I am The site users are saying that where they are, once they enter their place, you can easily use some PHP to set up your localization through your scripts. It is very easy. Actually very large, although it contains your examples of US / Eastern, it is not recommended that you apply T because it is only maintained for previous compatibility (under 'Other').
Then you can use this date ('z') to get offset in seconds if you store your datetime field as a Unix timestamp. It would be a trivial matter to add or subtract your offset. In this way, you are normalizing the data, which you store and keep it at zero offsets (GMT). When you query the data in the database, just add their offset, resulting in the step production you provided above. You can still use the date () to format the date / time in your local format type.
Comments
Post a Comment