Home  >  Article  >  Backend Development  >  How to convert time to number in php

How to convert time to number in php

藏色散人
藏色散人Original
2020-10-05 00:16:012980browse

php method to convert time into numbers: First create a PHP sample file; then enter the statement "echo strtotime("")" to convert time into numbers.

How to convert time to number in php

Recommended: "PHP Video Tutorial"

The code is as follows:

echo strtotime ("2012-03-22");
//结果1332374400
//说明:返回2012年3月22日0点0分0秒时间戳
echo time();
//说明:获取当前时间的时间戳

Related introduction:

The strtotime() function parses any English text date or time description into a Unix timestamp (number of seconds since January 1 1970 00:00:00 GMT).

The time() function returns the number of seconds since the Unix epoch (January 1 1970 00:00:00 GMT).

The above is the detailed content of How to convert time to number in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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