In PHP, you can use the date() function to convert the timestamp into year, month, day, hour, minute and second. The function of this function is to format the timestamp and convert it into a human-readable time format; syntax "date("Y-m-d H:i:s","timestamp")".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In PHP, you can use the date() function To convert the timestamp into year, month, day, hour, minute and second.
The date() function formats the timestamp, converts it to a human-readable time format, and returns the formatted date string.
Example:
<?php echo date("Y-m-d H:i:s","1635937055"); ?>
Output result:
Description:
Y - Year The four-digit representation of
y - The two-digit representation of the year
m - The numerical representation of the month (from 01 to 12)
M - A short text representation of the month (in three letters)
n - A numeric representation of the month without leading zeros (1 to 12)
h - 12-hour format, with leading zeros (01 to 12)
H - 24-hour format, with leading zeros (00 to 23)
i - Minutes, with leading zero (00 to 59)
s - Seconds, with leading zero (00 To 59)
u - Microseconds (new in PHP 5.2.2)
Recommended learning: "PHP Video Tutorial》
The above is the detailed content of How to convert timestamp to year, month, day, hour, minute and second in php. For more information, please follow other related articles on the PHP Chinese website!