1, conversion between seconds and date: select from _ unixtime (1388776825);
You can also define the time format as follows:
select from _ UNIXTIME( 1388776825,' % Y-% m-% d % H:% m:% s ');
Results: 2014-01-0403: 01:25.
Choice? From _ unixtime (1388776825,'% y year %m month %d')
Results: 20 14 1.4.
2. Convert seconds to date: select unix _ timestamp ('2014-03-2310:10: 40').
If you want to reverse the transformation, you can reverse the transformation through the unix_timestamp () function. Usage is as follows:
select UNIX _ TIMESTAMP(); //Get the seconds of the current time
select UNIX _ TIMESTAMP(' 20 14-03-23 10: 10:40 '); //Gets the number of seconds in the specified date format.
select UNIX _ TIMESTAMP(' 20 14-03-23 '); //Gets the number of seconds in the specified date format.
Extended data:
First, change the date type to int type?
select UNIX _ TIMESTAMP(' 20 17-9-22 13:54:45 ')
Second, from int type to date type?
select from _ UNIXTIME( 1506059685)
It should be noted that the conversion of an int value to DateTime needs to start from 0: 00: 00 and 0: 00 of June 1970 1, but it must be clear that this time is standard time, not Beijing time.
The time of data in the database is based on standard time. Therefore, it must be converted into the current time, and the China is +8. You can simply call ToLocalTime to achieve the effect.