MySQL中from_unixtime与unix_timestamp差别

查阅官档:

FROM_UNIXTIME(unix_timestamp)FROM_UNIXTIME(unix_timestamp,format)

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.

说明from_unixtime只是按照当前的时区,已指定的形式返回unix_timestamp值。

UNIX_TIMESTAMP()UNIX_TIMESTAMP(date)

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 UTC

不同点在与,unix_timestamp会受到本地时区的影响,有可能2个不同的timstamp对应一个unixtimestamp,而from_unixtime则是一一对应

MySQL中from_unixtime与unix_timestamp差别

时间: 2024-07-31 14:51:18

MySQL中from_unixtime与unix_timestamp差别的相关文章

mysql 中 unix_timestamp和from_unixtime函数

1.unix_timestamp 将时间转化为时间戳.(date 类型数据转换成 timestamp 形式整数) 没传时间参数则取当前时间的时间戳 mysql> select unix_timestamp();+------------------+| unix_timestamp() |+------------------+|       1361586358 |+------------------+1 row in set (0.01 sec) mysql> select unix_t

mysql 中 unix_timestamp,from_unixtime 时间戳函数

1.unix_timestamp 将时间转化为时间戳.(date 类型数据转换成 timestamp 形式整数) 没传时间参数则取当前时间的时间戳 mysql> select unix_timestamp();+------------------+| unix_timestamp() |+------------------+|       1361586358 |+------------------+1 row in set (0.01 sec) mysql> select unix_t

mysql中UNIX_TIMESTAMP()函数和php中time()函数的区别

http://tech.ddvip.com/2009-01/1231392775105351.html mysql 中:UNIX_TIMESTAMP(), UNIX_TIMESTAMP(date) 若无参数调用,则返回一个 Unix timestamp ('1970-01-01 00:00:00' GMT 之后的秒数) 作为无符号整数.若用date 来调用 UNIX_TIMESTAMP(),它会将参数值以'1970-01-01 00:00:00' GMT后的秒数的形式返回.date 可以是一个

MySQL时间函数from_unixtime()date_format()unix_timestamp()now()使用说明

now() 当前时间mysql> select now();+---------------------+| now() |+---------------------+| 2018-09-10 19:20:19 |+---------------------+123456unix_timestamp() 当前时间戳mysql> select unix_timestamp();+------------------+| unix_timestamp() |+------------------

MySQL中的内置系统函数

MySQL中的内置系统函数 用在SELECCT语句, 能及子句 where order by having 中 UPDATE DELETE, 函数中可以将字段名作为变量来用,变量的值就是这个列对应的每一行记录 一.字符串函数 php中用的函数,MySQl中大部也提供 1. CONCAT(S1,S2....SN): 把传入的参数连接成一个字符串 2. INSERT(str, x, y, insert): 将字符串X位置开始,y个字符串长度替换为字符串insert 3. LOWER(str) UPP

mysql中返回当前时间的函数或者常量

引用:http://blog.sina.com.cn/s/blog_6d39dc6f0100m7eo.html 1.1 获得当前日期+时间(date + time)函数:now() 除了 now() 函数能获得当前的日期时间外,MySQL 中还有下面的函数: current_timestamp()   current_timestamp localtime()   localtime localtimestamp()   localtimestamp     这些日期时间函数,都等同于 now(

Mysql中常用的函数

控制流函数IFNULL(expr1,expr2)如果expr1不是NULL,IFNULL()返回expr1,否则它返回expr2.IFNULL()返回一个数字或字符串值,取决于它被使用的上下文环境. mysql> select IFNULL(1,0); -> 1 mysql> select IFNULL(0,10); -> 0 mysql> select IFNULL(1/0,10); -> 10 mysql> select IFNULL(1/0,'yes');

mysql 中 时间和日期函数

原文链接: mysql 中 时间和日期函数 - redfox - 博客园 http://www.cnblogs.com/redfox241/archive/2009/07/23/1529092.html ----------------------------------------------------------------------------------------------------------------------------------------------------

mysql中函数(转)

一.数学函数ABS(x)   返回x的绝对值 BIN(x)   返回x的二进制(OCT返回八进制,HEX返回十六进制)CEILING(x)   返回大于x的最小整数值EXP(x)   返回值e(自然对数的底)的x次方FLOOR(x)   返回小于x的最大整数值GREATEST(x1,x2,...,xn)返回集合中最大的值LEAST(x1,x2,...,xn)      返回集合中最小的值LN(x)                    返回x的自然对数LOG(x,y)返回x的以y为底的对数MOD