Home > Article > Backend Development > How to convert timestamp to hour format in php
php method to convert timestamp to hour format: [date("Y/m/d H:i:s",1446634507)]. The date() function can format the timestamp into a more readable date and time.
php converts timestamp to 24-hour format
(Recommended tutorial: php video tutorial)
date("Y/m/d H:i:s",1446634507) //2015/11/04 18:55:77
Description: The
date() function can format the timestamp into a more readable date and time.
Syntax:
date ( string $format [, int $timestamp ] )
Parameters:
format Required. Specifies the format of the timestamp.
timestamp Optional. Specify timestamp. The default is the current date and time.
Example:
<?php echo date("Y/m/d") . "<br>"; echo date("Y.m.d") . "<br>"; echo date("Y-m-d"); ?>
Output result:
2016/10/21 2016.10.21 2016-10-21
Related recommendations: php training
The above is the detailed content of How to convert timestamp to hour format in php. For more information, please follow other related articles on the PHP Chinese website!