UNIX timestamp to date function: FROM_UNIXTIME () selectFROM_UNIXTIME (1156219870); date to UNIX timestamp function: UNIX_TIMESTAMP () SelectUNIX_TIMESTAMP (2006-11-0412: 23: 00); for example, mysql queries the unix timestamp of the current day.
Function for converting UNIX timestamp to date: FROM_UNIXTIME ()
Select FROM_UNIXTIME (1156219870 ); |
Date to UNIX timestamp function: UNIX_TIMESTAMP ()
Select UNIX_TIMESTAMP ('2017-11-04 12:23:00 ′); |
For example, the number of records queried by mysql on the current day:
$ SQL = "select * from message Where DATE_FORMAT (FROM_UNIXTIME (chattime), '% Y-% m-% d') = DATE_FORMAT (NOW (), '% Y-% m-% d') order by id desc "; |
Of course, you can also switch in PHP.
UNIX timestamp to date function: date ()
Date ('Y-m-d H: I: S', 1156219870 ); |
Date to UNIX timestamp function: strtotime ()
Strtotime ('2017-03-24 08:15:42 '); |