Time Zone Setting
VeloDB supports multiple time zone settings
There are multiple time zone related parameters inside VeloDB
- system_time_zone : When the server starts, it will be automatically set according to the machine setting time zone, and cannot be modified after setting.
- time_zone : the current time zone of the server, distinguish between session level and global level
Show and set time zone
-
show variables like '%time_zone%'
View the current time zone related configuration
-
SET time_zone = 'Asia/Shanghai'
This command can set the time zone at the session level, and it will fail after the connection is disconnected
-
SET global time_zone = 'Asia/Shanghai'
This command can set the time zone parameter at the global level, fe will persist the parameter, and it will not fail after the connection is disconnected
Effect of time zone setting
Time zone settings affect the display and storage of time zone-sensitive time values. This includes values displayed by time functions like NOW() or CURTIME(), as well as time values returned by some commands.
But it will not affect the less than value of the time type partition column in create table, nor will it affect the display of the value stored as date/datetime type.
Functions affected by timezone:
FROM_UNIXTIME
: Given a UTC timestamp, returns the datetime in the specified time zone: egFROM_UNIXTIME(0)
, returns the CST time zone:1970-01-01 08:00:00
.UNIX_TIMESTAMP
: Given a specified time zone date and time, return UTC timestamp: such as CST time zoneUNIX_TIMESTAMP('1970-01-01 08:00:00')
, return0
.CURTIME
: Returns the time in the specified time zone.NOW
: Return the date and time in the specified local time zone.CONVERT_TZ
: Convert a datetime from one specified time zone to another specified time zone.
Usage restrictions
Time zone values can be given in several formats, case insensitive:
- A string representing the UTC offset, such as '+10:00' or '-6:00'
- Standard time zone format, such as "Asia/Shanghai", "America/Los_Angeles"
- Abbreviated time zone formats such as "MET", "CTT" are not supported. Because the abbreviated time zone is ambiguous in different scenarios, it is not recommended to use it.
- In order to be compatible with some processing of VeloDB, it supports CST abbreviated time zone, and internally transfers CST to the Chinese standard time zone of "Asia/Shanghai"