Home > Article > Backend Development > How to remove hours, minutes and seconds from php time
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.
Recommendation: "PHP Video Tutorial"
php time to remove hours, minutes and seconds
<?php date('Y-m-d',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!