Simple implementation of PHP timestamp and specific time conversion, PHP specific time conversion_PHP tutorial

WBOY
Release: 2016-07-12 08:49:34
Original
776 people have browsed it

A simple implementation of PHP timestamp and specific time conversion, PHP specific time conversion

Three built-in functions:

time()   //获取UNIX系统时间戳

mktime(hour,minute,second,month,day,year)  //将指定时间转化为时间戳

date(时间格式,时间戳)   //将时间戳转化为方便阅读的时间
Copy after login

time -> date:

$now = time();
echo "时间戳是 " .$now;
echo "创建日期是 " . date("Y-m-d h:i:s", $now);

输出:

时间戳是 1404610907
创建日期是 2014-07-06 09:41:47
Copy after login

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
Copy after login

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1136655.htmlTechArticleA simple implementation of PHP timestamp and specific time conversion, PHP three built-in functions for specific time conversion: time() //Get the UNIX system timestamp mktime(hour,minute,second,month,day,year) //Will point to...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template