Three built-in functions:
time() //获取UNIX系统时间戳 mktime(hour,minute,second,month,day,year) //将指定时间转化为时间戳 date(时间格式,时间戳) //将时间戳转化为方便阅读的时间
time -> date:
$now = time(); echo "时间戳是 " .$now; echo "创建日期是 " . date("Y-m-d h:i:s", $now); 输出: 时间戳是 1404610907 创建日期是 2014-07-06 09:41:47
mktime -> date:
$d=mktime(9, 41, 47, 7, 6, 2014); echo "时间戳是 " .$d; echo "创建日期是 " . date("Y-m-d h:i:s", $d); 输出: 时间戳是 1404610907 创建日期是 2014-07-06 09:41:47
Note:
Generally, when registering or logging in, the time function is used by default to obtain the current timestamp. When there is a business that needs to specify a specific time, the mktime function can be used to convert it into a specific timestamp according to the specific time, and the date function can be used to convert the timestamp. The reverse is converted into a specific time for easy viewing.
The above simple implementation of PHP timestamp and specific time conversion is all the content shared by the editor. I hope it can give you a reference, and I also hope that everyone will support Bangkejia.