function Getmillisecond () {
List ($t 1, $t 2) = Explode (", microtime ());
Return $t 2. ‘.‘ . Ceil (($t 1 * 1000));
Return $t 2. Ceil (($t 1 * 1000));
}
Echo Getmillisecond ();
The above method can obtain a 13-bit timestamp, which is written to the MySQL table.
If the original time in the table is a date format. Just change it.
Example: CU is a table. Mtime is a field that is placed in a 13-bit timestamp. Time is the original write, formatted as datatime.
Update CU Set mtime = Unix_timestamp (time) *1000;
Report:
Unix timestamp converted to date function: From_unixtime ()
| Select From_unixtime (1156219870); |
Date conversion to UNIX timestamp function: Unix_timestamp ()
| Select unix_timestamp (' 2006-11-04 12:23:00′); |
Example: MySQL Query the number of records on the day:
| $sql = "SELECT *" from the 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 choose to convert in PHP
Unix timestamp converted to date function: Date ()
| Date (' y-m-d h:i:s ', 1156219870); |
Date conversion to UNIX timestamp function: Strtotime ()
Strtotime (' 2010-03-24 08:15:42 ');
13-bit timestamp in Php+mysql