MySQL - 翻译 - 5.1Reference Manual参考手册 - 11.6. Date and Time Functions日期和时间函数 - FROM_UNIXTIME将UNIX时间戳格式化为日期
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'
or YYYYMMDDHHMMSS.uuuuuu
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 the UNIX_TIMESTAMP()
function.
返回'YYYY-MM-DD HH:MM:SS'或YYYYMMDDHHMMSS.uuuuuu 格式值的unix_timestamp参数表示,具体格式取决于该函数是否用在字符串中或是数字语境中。该值以当前时间区域中表示,unix_timestamp
是一个类似于使用UNIX_TIMESTAMP()函数生成的内部时间戳值。
If format
is given, the result is formatted according to the format
string, which is used the same way as listed in the entry for the DATE_FORMAT()
function.
若format 已经给出,则结果的格式是根据format 字符串而定。 format 可以包含同DATE_FORMAT() 函数输入项列表中相同的说明符。
mysql>SELECT FROM_UNIXTIME(1196440219);
-> '2007-11-30 10:30:19'
mysql>SELECT FROM_UNIXTIME(1196440219) + 0;
-> 20071130103019.000000
mysql>SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(),
->'%Y %D %M %h:%i:%s %x');
-> '2007 30th November 10:30:59 2007'
Note: If you use UNIX_TIMESTAMP()
and FROM_UNIXTIME()
to convert between TIMESTAMP
values and Unix timestamp values, the conversion is lossy because the mapping is not one-to-one in both directions. For details, see the description of the UNIX_TIMESTAMP()
function.
注意:如果使用UNIX_TIMESTAMP()和FROM_UNIXTIME()在TIMESTAMP值和Unix时间戳值之间转换,由于双向不是一对一映射,因此转换是有损的。细节请参考UNIX_TIMESTAMP()函数。
[MySQL - 5.1Reference Manual参考手册 - 11 Functions and Operators函数和操作符 - 11.6. Date and Time Functions日期和时间函数 - FROM_UNIXTIME将UNIX时间戳格式化为日期 - 文档]
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_from-unixtimehttp://dev.mysql.com/doc/refman/5.1/zh/functions.html#date-and-time-functions
[MySQL - 官方网站]
[MySQL - 关键词]
mysql
[MySQL - 相关论坛]
[MySQL - 下载]
http://dev.mysql.com/downloads/
[MySQL - 5.1 Reference Manual参考手册]
12 SQL Statement Syntax - SQL语句语法 - 12.8 MySQL Compound-Statement Syntax - MySQL复合语句语法 - 12.8.6 Flow Control Constructs流程控制结构 - 12.8.6.2. CASE Statement - CASE语句, http://dev.mysql.com/doc/refman/5.1/en/case-statement.html
13. SQL语句语法 - 13.1. 数据定义语句 - 13.1.5. CREATE TABLE语法, http://dev.mysql.com/doc/refman/5.1/zh/sql-syntax.html#create-table