How to use php date function

藏色散人
Release: 2023-04-05 11:18:01
Original
12016 people have browsed it

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

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);
?>
Copy after login

Output:

2012-04-25
Copy after login

php date() function example 2

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

Output:

2012-04-24 16:00:00
Copy after login

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!