In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
How to use the FROM_UNIXTIME () and UNIX_TIMESTAMP () functions in MySQL. Aiming at this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
1. FROM_UNIXTIME (unix_timestamp)
Parameter: usually a ten-digit number, such as 1344887103
Return values: there are two types, either a string like 'YYYY-MM-DD HH:MM:SS', or a number like YYYYMMDDHHMMSS.uuuuuu, depending on the form in which the function is called.
1mysql > select FROM_UNIXTIME (1344887103); 2murmur3 |
FROM_UNIXTIME (1344887103) | 4 years Musashi 5 |
2012-08-14 03:45:03 | 6-month-old Musashi 7
one
Row in set (0.00)
Sec)
2. FROM_UNIXTIME (unix_timestamp, format)
Parameter unix_timestamp: it has the same meaning as the parameter in method FROM_UNIXTIME (unix_timestamp)
Parameter format: the format of the converted time string
Return value: a string displayed in the specified time format
View
Sourceprint?
01mysql > select FROM_UNIXTIME (1344887103 (1344887103)% YMY% MMI% D
% HRV% iRU% s'); 02% HV% iRU% s'); 02% hRV% iRU% s')
FROM_UNIXTIME (1344887103% Ymuri% MMI% D
% HRV% iRU% s')
| | 04 / 04 / 2 / 5 / 4 / 5 / 5 | |
2012-August-14th 03:45:03 | 06MB / MB / 071
Row in set (0.00)
Sec) 08mysql > select FROM_UNIXTIME (1344887103 recording% YMY% MMI% D
% HRV% iRU% s'); 09% hRV% iRU% s').
FROM_UNIXTIME (1344887103% Ymuri% mmi% D
% HRV% iRU% s')
| | 11 / 11 / 12 / 12 | |
2012-08-14th 03:45:03 | 13th Musashi 14151
Row in set (0.00)
Sec)
1. UNIX_TIMESTAMP ()
Return value: the UNIX-formatted numeric string of the current time, or the UNIX timestamp (the number of seconds from the UTC time '1970-01-01 00 UTC time'), usually ten digits, such as 1344887103. The result of new Date (). GetTime () in Java is 13 bits, while that of the database is 10 bits.
1mysql > select unix_timestamp (); 2murmur3 |
Unix_timestamp () | 4 colors 5 |
| 1344887103 | 6 years of music 71 |
Row in set (0.00)
Sec)
2. UNIX_TIMESTAMP (date)
Parameters: date may be a DATE string, a DATETIME string, a TIMESTAPE string, or a numeric string similar to YYMMDD or YYYYMMDD.
Return: the number of seconds between '1970-01-01 UTC time' and the parameter. The server interprets the parameter date as a value of the current time zone and converts it into an internal time in UTC format. The client can set the current time zone by itself. When UNIX_TIMESTAMP () is used for a TIMESTAMP column, the function directly returns the value of the internal timest if you pass an out-of-range time to UNIX_TIMESTAMP (), its return value is zero.
01mysql > SELECT UNIX_TIMESTAMP (); 02 copyright 03 |
UNIX_TIMESTAMP () | 04copyright 05 |
1344888895 | 06MB / m 071
Row in set (0.00)
Sec) 0809mysql > SELECT UNIX_TIMESTAMP ('2012-08-14
16 / 19 / 23 / 11 / 10 / 10 / 11 / 10 / 11 / 11 / 11 / 11 / 11 / 11 / 11 / 11 / 11 / 11 / 11 / 11 / 11 / 11 / 11 / 11.
UNIX_TIMESTAMP ('2012-08-14
16, 19, 23')
| | 12 / 12 / 12 / 12 / 13 | |
| 1344932363 | 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 14 / 15 / 14 / 14 / 14 / 15 / 15 / 14 / 14 / 14 / 15 / 15 / 14 / 14 / 14 / 15 / 15.
Row in set (0.00)
Sec)
Note: if you use UNIX_TIMESTAMP () and FROM_UNIXTIME () to convert the TIMESTAMP value to the Unix timestamp value, the precision will be lost because the mapping is not one-to-one in both directions. For example, due to a change in the local time zone, it is possible that two UNIX_TIMESTAMP () will map to the same Unix timestamp value. FROM_UNIXTIME () only maps to the original timestamp value.
This is the answer to the question about how to use the FROM_UNIXTIME () and UNIX_TIMESTAMP () functions in MySQL. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
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.