MySQL中from_unixtime與unix_timestamp差異

查閱官檔:html

 FROM_UNIXTIME(unix_timestamp)FROM_UNIXTIME(unix_timestamp,format)mysql

Returns a representation of the unix_timestamp argument as a value in 'YYYY-MM-DD HH:MM:SS' orYYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone. unix_timestamp is an internal timestamp value such as is produced by theUNIX_TIMESTAMP() function.sql

說明from_unixtime只是按照當前的時區,已指定的形式返回unix_timestamp值。express

 UNIX_TIMESTAMP()UNIX_TIMESTAMP(date)spa

If called with no argument, returns a Unix timestamp (seconds since '1970-01-01 00:00:00' UTC) as an unsigned integer. If UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds since '1970-01-01 00:00:00' UTC. date may be a DATE string, a DATETIME string, a TIMESTAMP, or a number in the format YYMMDD or YYYYMMDD. The server interprets date as a value in the current time zone and converts it to an internal value in UTCunix

不一樣點在與,unix_timestamp會受到本地時區的影響,有可能2個不一樣的timstamp對應一個unixtimestamp,而from_unixtime則是一一對應

code

相關文章
相關標籤/搜索