In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the detailed explanation of from_unxitime grammar and format format. I hope I can add and update some knowledge to you. If you have any other questions you need to know, you can continue to follow my updated article in the industry information.
We generally use the field type int (11) timestamp to save time, which makes it easier to query efficiently. But this has a drawback, the displayed timestamp, it is difficult to know the real date and time.
Mysql provides a timestamp formatting function from_unixtime to convert the format
From_unxitime syntax description: from_unixtime (unix_timestamp, format)
Returns a string of Unix timestamps, formatted according to format. If format is empty, the format of Y-%m-%d H:%i:%s is used by default
For example:
Mysql > select from_unixtime (1459338786) +-- + | from_unixtime (1459338786) | +-- + | 2016-03-30 19:53:06 | +-- + 1 row in set (1459338786 sec) mysql > select from_unixtime (1459338786) '% Y-%m-%d% HRV% iRU% s') +-+ | from_unixtime (1459338786 '% Y-%m-%d% HRV% iRV% s') | +-- + | 2016-03-30 19:53:06 | +-- -- + 1 row in set (0.00 sec) format format description:
% M month name (January~December)
% W week name (Sunday~Saturday)
% D the date of the month with the English prefix (1st, 2nd, 3rd, etc.). )
% Y year, number, 4 digits
% y year, number, 2 digits
An abbreviated name of the week (Sun~Sat)
Number of days in d month, number (0031)
Number of days in% e month, number (0,31)
% m month, number (01y12)
% c month, number (1x 12)
% b abbreviated month name (Jan~Dec)
% j days of the year (001mm 366)
% H hours (000023)
% k hours (0,23)
% h hours (01y12)
% I hours (01pm 12)
L hours (1x 12)
% I minutes, number (0059)
% r time, 12 hours (hh:mm:ss [AP] M)
% T time, 24 hours (hh:mm:ss)
% s seconds (00059)
% s seconds (00059)
% p AM or PM
% w days in a week (0=Sunday ~ 6=Saturday)
% U week (0,52), here Sunday is the first day of the week
% u week (0,52), here Monday is the first day of the week
% one text%
Example: statistics by hour mysql > select from_unixtime (addtime,'%Y-%m-%d% H') as date,count (*) from `table` group by from_unixtime (addtime,'%Y-%m-%d% H') +-+-+ | date | count (*) | +-+-+ | 2016-03-30 19 | 409 | | 2016-03-30 20 | 161 | +-+-+ 2 rows in set (0.00 sec)
This article explains how to use the mysql timestamp formatting function from_unixtime. Please follow us for more information.
Related recommendations:
Notes on the use of mysql functions concat and group_concat
Explain how to deal with mysql innodb startup failure and can't be restarted.
Explain how php can get the specified date.
The above are the details of from_unxitime grammar and format format, please pay attention to other related articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.