Home>Article>Backend Development> How to use php time function?

How to use php time function?

藏色散人
藏色散人 Original
2019-05-23 10:20:55 4397browse

time() is a built-in function in PHP, used to return the number of seconds from the Unix epoch to the current time (unix timestamp), the syntax is "time();", no parameters; then you can use PHP The date() function in will convert the returned seconds to the current date, with the syntax "date("Y-m-d",time())".

How to use php time function?

time() function

Function: Returns the unix timestamp of the current time

Syntax :time()

Parameters: The time() function only returns the unix timestamp of the current time, without parameters.

Description: Returns the number of seconds since the Unix epoch (00:00:00 GMT on January 1, 1970) to the current time.

Example 1

Output:

1523947811

Example 2: time() date() converts unix timestamp to current date

"; echo "转换为具体时间为:".(date("Y-m-d",$time)); ?>

Output:

当前时间戳为:1524705185 转换为具体时间为:2018-04-26

The above is the detailed content of How to use php time function?. 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
Previous article:What does php mean? Next article:What does php mean?