convert-tz

date time right in app but wrong in mysql [time zone]

喜欢而已 提交于 2020-01-24 08:50:29
问题 Problem: Right time in app server, wrong in database. I am in China, Time Zone is UTC+8 I use hibernate. Entity definition as following (language: Scala) class CargoJournal { @Type(`type`="org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime") var deliverTime: LocalDateTime = _ @Temporal(TemporalType.TIMESTAMP) @Column(nullable=false) var logDate:Date = _ } I open the hibernate log, see following in my app server. Current time is Thu Sep 13 11:08:44 CST 2012 insert into wms_history

Why does MySQL CONVERT_TZ alter the seconds after timezone adjustment?

六眼飞鱼酱① 提交于 2019-12-23 05:33:37
问题 I'm storing UTC datetime values in MySQL. I use CONVERT_TZ to handle timezone conversion to query/save local datetimes to/from UTC in the database. Upon testing I noticed this strange peculiarity in how the conversion works. Can anyone explain why it is MySQL is adding 23 seconds when using the -4:00 hour offset, but not when using the equivalent timezone label? select convert_tz('2009-06-12 01:00:00', 'UTC', '-4:00') 2009-06-11 21:00:23 select convert_tz('2009-06-12 01:00:00', 'UTC', 'US

convert_tz returns null

て烟熏妆下的殇ゞ 提交于 2019-12-17 02:44:20
问题 I know this sounds stupid, but when I use SELECT CONVERT_TZ('2004-01-01 12:00:00','UTC','Asia/Jakarta') AS time it outputs NULL. I'm using MySQL Workbench in Ubuntu 12.04 64 bit, and it works in my other laptop/os (also using MySQL Workbench). 回答1: This will happen if you haven't loaded the time zone table into mysql. mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql 回答2: I found this thread after spending some time trying to figure out why after running the command in the

converting datetime to different timezone in C++/boost

放肆的年华 提交于 2019-12-10 21:36:27
问题 I have price data for the Indian stock market, but the time and date stamp on it is GMT, so I can work with the data representing the correct date and time. I need to convert the date and time for some of the records in my DB into IST from GMT, my current time zone. mysql> desc price_hist; +---------------+-----------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+-----------------------+------+-----+---------+------------

grails/mysql timezone change

本秂侑毒 提交于 2019-12-07 23:51:21
问题 Whats the best way to accomplish changing the timezone of an app? The way I see it the following must occur: Server TZ is changed by sys admin mysql must be restarted. every time based column in the database must have all values updated, using convert_tz or equivalent. So either a mysql script must be written or a grails script that loads every row for each class, updating all the time fields. Obviously the server should be taken down while this is happening, and backups must be in place

grails/mysql timezone change

百般思念 提交于 2019-12-06 10:49:34
Whats the best way to accomplish changing the timezone of an app? The way I see it the following must occur: Server TZ is changed by sys admin mysql must be restarted. every time based column in the database must have all values updated, using convert_tz or equivalent. So either a mysql script must be written or a grails script that loads every row for each class, updating all the time fields. Obviously the server should be taken down while this is happening, and backups must be in place incase of an error. Is there a better/easier way to do this? Jared Java does not use time zones when using

Convert local TIME_STAMP to UTC time

我怕爱的太早我们不能终老 提交于 2019-12-06 07:53:30
问题 I have two tables with time stamps TABLE1 with TIME_STAMP in local time TABLE2 with TIME_STAMP in UTC I need to do something like select count(*) from TABLE1 where TIME_STAMP > TABLE2.TIME_STAMP The problem is that this app will be deployed in multiple time zones so I cannot use the following SELECT CONVERT_TZ(TABLE2.TIME_STAMP,'EST','UTC') because ' EST ' can be any time zone. Is there a way of getting local time zone code and substituting it as second argument? Or is there a better and more

Convert local TIME_STAMP to UTC time

本秂侑毒 提交于 2019-12-04 15:03:06
I have two tables with time stamps TABLE1 with TIME_STAMP in local time TABLE2 with TIME_STAMP in UTC I need to do something like select count(*) from TABLE1 where TIME_STAMP > TABLE2.TIME_STAMP The problem is that this app will be deployed in multiple time zones so I cannot use the following SELECT CONVERT_TZ(TABLE2.TIME_STAMP,'EST','UTC') because ' EST ' can be any time zone. Is there a way of getting local time zone code and substituting it as second argument? Or is there a better and more direct approach to solving my issue? NOTE: Both TABLE1 and TABLE2 TIME_STAMPS have to remain as local

Detect if a date is in Daylight saving time in MySql

不羁岁月 提交于 2019-12-02 08:54:30
问题 I have inherited a legacy application where all the dates and times are stored in the local timezone (UK). I am not in a position to change how these are stored. However, the requirement is to display all the dates in GMT within the app. Therefore when I retrieve a list of events from the database I need it to display them all in this time format whilst observing if daylight saving is in operation for each particular event date. Using the following logic I can determine if daylight saving is

Detect if a date is in Daylight saving time in MySql

孤街醉人 提交于 2019-12-02 03:01:08
I have inherited a legacy application where all the dates and times are stored in the local timezone (UK). I am not in a position to change how these are stored. However, the requirement is to display all the dates in GMT within the app. Therefore when I retrieve a list of events from the database I need it to display them all in this time format whilst observing if daylight saving is in operation for each particular event date. Using the following logic I can determine if daylight saving is active within the query: IF(CAST(TIMEDIFF(NOW(), UTC_TIMESTAMP()) AS SIGNED) >0, DATE_FORMAT(CONVERT_TZ