Home > Backend Development > PHP Problem > How to use date() in php to get the current date

How to use date() in php to get the current date

青灯夜游
Release: 2023-03-13 07:54:01
Original
2328 people have browsed it

In PHP, you only need to set a parameter in the date() function, and the parameter value is "d" to get the current time. The date() function can format the current local time or the specified timestamp (when setting the second parameter). When the required parameter is set to "d", the day of the month can be calculated for the specified time.

How to use date() in php to get the current date

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

php uses date( ) Get the current number

<?php
header("Content-type:text/html;charset=utf-8");
echo &#39;当前是:&#39;.date("d")."号";
?>
Copy after login

Output:

How to use date() in php to get the current date

How to use date() in php to get the current date

# #Description:

date() function formats the local date and time and returns the formatted date string.

Syntax:

date(format,timestamp);
Copy after login
  • format Required parameter, specifies the format of the output date string; when the value is "d", the day of the month is output ( from 01 to 31).

  • timestamp Optional. Specifies an integer Unix timestamp. The default is the current local time (time()).​

Recommended study: "

PHP Video Tutorial"

The above is the detailed content of How to use date() in php to get the current date. 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