1. UNIX timestamp converted to date function: From_unixtime ()
[SQL]View PlainCopy
- Select From_unixtime (1156219870);
Output: 2006-08-22 12:11:10
2. Date conversion to UNIX timestamp function: Unix_timestamp ()
[SQL]View PlainCopy
- Select unix_timestamp (' 2006-11-04 12:23:00 ');
[SQL]View PlainCopy
- Output: 1162614180
[SQL]View PlainCopy
- Select Unix_timestamp (now ());
[SQL]View PlainCopy
[SQL]View PlainCopy
- Output Current time stamp
Example: MySQL Query the number of records on the day:
[SQL]View PlainCopy
- $sql = "select *" From the message Where date_format (From_unixtime (chattime), '%y-%m-%d ') = Date_format (now (), '% y-%m-%d ') ORDER by ID desc ";
PHP Mode conversion:
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 ');
MySQL timestamp and date format for mutual conversion