"MySQL" timestamp conversion bitsCN.com
1 NOW () // Current Time 2 SYSDATE () // Current Time 3 CURRENT_TIMESTAMP 4 returns the current date and time in 'yyyy-MM-DD HH: MM: SS' or YYYYMMDDHHMMSS format, it depends on whether the function is used in a string or in the context of a number. 5 mysql> select NOW (); 6-> '2017-12-15 23:50:26 '7 mysql> select NOW () + 0; 8-> 1997
1 UNIX_TIMESTAMP (date) 2 If no parameter is called, a Unix timestamp (the number of seconds since '2017-01-01 00:00:00 'GMT) is returned ). If UNIX_TIMESTAMP () is called with a date parameter, it returns the second value starting from '2017-01-01 00:00:00 'GMT. Date can be a number of a DATE string, a DATETIME string, a TIMESTAMP, or a local time in YYMMDD or YYYYMMDD format. 3 mysql> select UNIX_TIMESTAMP (); 4-> 8822263575 mysql> select UNIX_TIMESTAMP ('2017-10-04 22:23:00 '); 6-> 1997 when UNIX_TIMESTAMP is used for a TIMESTAMP column, the function will directly accept the value without the implicit "string-to-unix-timestamp" transformation.
1 FROM_UNIXTIME (unix_timestamp) 2 returns the value represented by the unix_timestamp parameter in 'yyyy-MM-DD HH: MM: SS' or YYYYMMDDHHMMSS format, it depends on whether the function is used in a string or a number context. 3 mysql> select FROM_UNIXTIME (875996580); 4-> '2017-10-04 22:23:00 '5 mysql> select FROM_UNIXTIME (1997) + 0; 6-> 875996580
1 FROM_UNIXTIME (unix_timestamp, format) 2 returns a string representing the Unix time Mark, formatted according to the format string. Format can contain the same modifier as the entries listed by the DATE_FORMAT () function. 3 mysql> select FROM_UNIXTIME (UNIX_TIMESTAMP (), 4' % Y % D % M % h: % I: % s % X '); 5-> '2014 23rd December 03:43:30 x'
1 SEC_TO_TIME (seconds) 2 returns the seconds parameter, which is converted to hour, minute, and second. The value is formatted in 'hh: MM: SS' or HHMMSS, it depends on whether the function is used in a string or a number context. 3 mysql> select SEC_TO_TIME (2378); 4-> '00: 39: 38 '5 mysql> select SEC_TO_TIME (2378) + 0; 6-> 3938
TIME_TO_SEC (time) returns the time parameter, which is converted to seconds. Mysql> select TIME_TO_SEC ('22: 23: 00');-> 80580 mysql> select TIME_TO_SEC ('00: 39: 38');-> 2378BitsCN.com