Reprint Please indicate the source: The Curtain Roll westerly column (Http://blog.csdn.net/ljxfblog)
Recently has been doing some of the game backstage tools about data statistics work, for MySQL time function used more, but used to forget, and easy to confuse, so in this record the use of functions, later gradually complete.
1, now (), returns the current time format.
> select now ();
> ' 2014-11-24 18:38:17 '
2, Curdate (), returns the current time format.
> select Curdate ();
> ' 2014-11-24 '
3, Unix_timestamp (), converted from ' yyyy-mm-dd HH:MM:SS ' to the number of seconds since January 1, 1970 8 o'clock.
> select Unix_timestamp ();
> 1416825969
> select Unix_timestamp (' 1997-10-04 22:23:00 ');
> 875996580
4, From_unixtime (), from January 1, 1970 to 8 o'clock since the number of seconds converted to the ' yyyy-mm-dd HH:MM:SS ' lattice -style time, or convert it into a 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 a custom format.
> select Date_format (Now (), "%y%m%d")
>141124
About MySQL common time functions