Home >Backend Development >PHP Tutorial >How to use php date function

How to use php date function

藏色散人
藏色散人Original
2019-02-21 15:24:2912065browse

php The date function is used to format the timestamp into a more readable date and time. The syntax of this function is "date(format, timestamp)". The format parameter cannot be omitted. It specifies how to Format date or time.

How to use php date function

How to use the php date() function?

php The date() function formats the timestamp into a more readable date and time.

Syntax:

date(format,timestamp)

Parameters:

format: Required. Specifies the format of the timestamp.

timestamp: Optional. Specify timestamp. The default is the current time and date.

Note: The format parameters of the date() function are required, and they specify how to format the date or time.

php date() function example 1

<?php
echo date("Y-m-d",1335283200);
?>

Output:

2012-04-25

php date() function example 2

<?php
//将时间戳以年月日时分秒的形式输出
echo date("Y-m-d H:i:s",1335283200);
?>

Output:

2012-04-24 16:00:00

This article is about how to use the date function. I hope it will be helpful to friends who need it!

The above is the detailed content of How to use php date 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