In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you "mysql timestamp how to convert date format", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "mysql timestamp how to convert date format" this article.
In mysql, you can use the FROM_UNIXTIME () function to convert a specified timestamp to a date format, which converts the UNIX timestamp into a date-time value in a normal format, with the syntax "SELECT FROM_UNIXTIME (timestamp, format").
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
In mysql, you can use the FROM_UNIXTIME () function to convert a specified timestamp to a date format.
The FROM_UNIXTIME () function converts the UNIX timestamp into a date-time value in a normal format. (and the UNIX_TIMESTAMP () function are inverse functions each other. )
Syntax:
Select FROM_UNIXTIME (unix_timestamp,format)
Format is an optional parameter and can have the following values:
% 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 (00. 31)
Number of days in% e month, number (0... 31)
% m month, number (01... 12)
% c month, number (1 …... 12)
% b abbreviated month name (Jan... Dec)
% j days of the year (001... 366)
% H hours (00. 23)
% k hours (0. 23)
% h hours (01 …... 12)
% I hours (01 …... 12)
% l hours (1 …... 12)
% I minutes, number (00. 59)
% r time, 12 hours (hh:mm:ss [AP] M)
% T time, 24 hours (hh:mm:ss)
% s seconds (00. 59)
% s seconds (00. 59)
% p AM or PM
% w days in a week (0=Sunday... 6=Saturday)
% U week (0 …... Here Sunday is the first day of the week
% u weeks (0. Here Monday is the first day of the week
%% one word "%".
Example:
(1) does not contain format parameter, and returns the format:
SELECT FROM_UNIXTIME (addtime) FROM `web_ game` ORDER BY ID desc LIMIT 5
The format of the return is as follows:
2020-03-23 15 purl 28purl 462020-03-23 15 purl 1643 2020-03-23 15 purl 05 purl 182020-03-23 15 purl 01purl 012020-03-23 14:50:36
(2) contains format parameters:
SELECT FROM_UNIXTIME (addtime,'%Y-%m-%d') FROM `web_ game` ORDER BY ID desc LIMIT 5
The format of the return is as follows:
2020-03-232020-03-232020-03-232020-03-232020-03-23 above are all the contents of the article "how to convert mysql timestamps to date format". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.