Home  >  Article  >  Backend Development  >  How to remove hours, minutes and seconds from php time

How to remove hours, minutes and seconds from php time

藏色散人
藏色散人Original
2020-08-15 10:42:355132browse

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(日期)) ?>

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)

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");
?>

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!

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