Home > Backend Development > PHP Problem > How to use date in php to display the day of the month

How to use date in php to display the day of the month

青灯夜游
Release: 2023-03-14 11:42:01
Original
2936 people have browsed it

The way to use date to display the day of the month in php is: "echo date('m', timestamp)."month".date('d', timestamp)."day";" ;The first parameter of the date() function is set to "m" to output the number of the month represented, and the first parameter is set to "d" to output the number representing the number of days in the month.

How to use date in php to display the day of the month

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

php uses date to display the day of the month Date

<?php
header("Content-type:text/html;charset=utf-8");
$d="1639908825";
echo "指定时间戳为: ".date(&#39;m&#39;,$d)."月".date(&#39;d&#39;,$d)."日";
?>
Copy after login

How to use date in php to display the day of the month

Note:

PHP date() function can format the timestamp into a more readable format OK date and time.

Grammar:

date ($format [, $timestamp ] )
Copy after login
  • format Required. Specifies the format of the timestamp. When the format value is set to:

    • "m": the month number (01 - 12) can be output

    • "d": Can output a number representing the number of days in the month (01 - 31)

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

If timestamp is omitted, the month and day of the current time can be output.

<?php
header("Content-type:text/html;charset=utf-8");
echo "现在是: ".date(&#39;m&#39;)."月".date(&#39;d&#39;)."日";
?>
Copy after login

How to use date in php to display the day of the month

How to use date in php to display the day of the month

Recommended learning: "PHP Video Tutorial"

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