http://tech.ddvip.com/2009-01/1231392775105351.html MySQL: Unix_timestamp (), Unix_timestamp (date)
If no parameter is called, returns a Unix timestamp (the number of seconds after the ' 1970-01-01 00:00:00 ' GMT) as an unsigned integer. If you call Unix_timestamp () with date, it returns the value of the parameter in the form of a number of seconds after the ' 1970-01-01 00:00:00 ' GMT. Date can be a date string, a DateTime string, a timestamp, or a number in the YYMMDD or YYYMMDD format of a local time.
Mysql> Select Unix_timestamp ();
882226357
mysql> Select unix_timestamp (' 1997-10-04 22:23:00 ');
875996580
When Unix_timestamp is used in the TIMESTAMP column, the function returns the internal timestamp value directly without any implied "string-to-unix-timestamp" conversions. If you pass an overflow date to Unix_timestamp (), it will return 0, but be aware that only the basic range check will be fulfilled (the year is from 1970 to 2037, the month is from 01 to 12, and the date is from 01 to 31).
Here we can use
From_unixtime (Unix_timestamp), From_unixtime (Unix_timestamp,format) to format a unix_timestamp () timestamp, it will return ' YYYY-MM-DD HH: The Unix_timestamp parameter of the Mm:ss ' or YYYYMMDDHHMMSS format value, depending on whether the function is used in a string or in a digital context.
If format is already given, the result is formatted according to the format string. Format can contain the same descriptor as the Date_format () function entry list.
Mysql> Select from_unixtime (875996580);
' 1997-10-04 22:23:00 '
Mysql> Select From_unixtime (875996580) + 0;
19971004222300
Mysql> Select From_unixtime (Unix_timestamp (),
'%Y%d%M%h:%i:%s%x ');
' 2003 6th August 06:22:58 2003 '
In PHP: Time ()
Time--Returns the current Unix timestamp
Returns the number of seconds since the Unix era (January 1, 1970 00:00:00 GMT) to the current time.
Literally, they are the same, returning the number of seconds since the Unix era to the current time.
I did a test on the same server and found that the results were the same.
Use From_unixtime (1156219870, '%y-%m-%d ') in MySQL
and PHP with date ("y-m-d", 1156219870) The result is the same! The only thing that's not sure is that one responds more quickly. But I'm still inclined to use the time () function in PHP
The difference between the Unix_timestamp () function in MySQL and the time () function in PHP