Mysql common time functions
Reprinted please indicate the source: curtain roll west wind column (http://blog.csdn.net/ljxfblog)
Recently, I have been playing the game back-end tool for some data statistics work. I have used a lot of mysql time functions, but I forgot it once I used it and it is easy to confuse it, therefore, record the used functions here and complete them gradually.
1. now (), returns the current time format.
> Select NOW ();
> '2017-11-24 18:38:17'
2. CURDATE () returns the current time format.
> Select CURDATE ();
> '2017-11-24'
3, UNIX_TIMESTAMP (), from 'yyyy-MM-DD HH: MM: ss' format time to the number of seconds since January 1, 1970.
> Select UNIX_TIMESTAMP ();
> 1416825969
> Select UNIX_TIMESTAMP ('2017-10-04 22:23:00 ');
> 875996580
4, FROM_UNIXTIME (), from January 1, 1970 8 points since the number of seconds converted to 'yyyy-MM-DD HH: MM: ss' format time, or converted to custom format.
> Select FROM_UNIXTIME (875996580 );
> 1997-10-05 04:23:00
> Select FROM_UNIXTIME (875996580, "% y % m % d ")
> 19971005
5. DATE_FORMAT (), converted from 'yyyy-MM-DD HH: MM: ss' format time to custom format.
> Select DATE_FORMAT (NOW (), "% y % m % d ")
> 141124