How to remove hours, minutes and seconds from php time

藏色散人
Release: 2023-03-04 14:12:01
Original
5133 people have browsed it

How to remove hours, minutes and seconds from php time: First create a PHP sample file; then use the "date('Y-m-d',strtotime(date))" method to get the time and remove hours, minutes and seconds.

How to remove hours, minutes and seconds from php time

Recommendation: "PHP Video Tutorial"

php time to remove hours, minutes and seconds

<?php date(&#39;Y-m-d&#39;,strtotime(日期)) ?>
Copy after login

Related introduction:

The date() function in PHP is used to format date or time.

PHP Date() function formats a timestamp into a more readable date and time.

date(format,timestamp)
Copy after login

Parameter description

format required. Specifies the format of the timestamp.

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

Note: A timestamp is a sequence of characters that represents the date and event when a specific event occurred.

Get a simple date

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

Here are some characters commonly used for dates:

d - represents the day of the month (01-31)

m - represents the month (01-12 )

Y - represents the year (four digits)

1 - represents a day of the week

Other characters, such as "/", "." or "- " can also be inserted into characters to add additional formatting.

The following example formats today's date in three different ways:

Example

<?php
echo "今天是 " . date("Y/m/d") . "<br>";
echo "今天是 " . date("Y.m.d") . "<br>";
echo "今天是 " . date("Y-m-d") . "<br>";
echo "今天是 " . date("l");
?>
Copy after login

The above is the detailed content of How to remove hours, minutes and seconds from php time. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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