Home>Article>Backend Development> How to convert timestamp to hour format in php

How to convert timestamp to hour format in php

王林
王林 Original
2020-09-28 09:27:18 3433browse

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.

How to convert timestamp to hour format in php

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:

"; echo date("Y.m.d") . "
"; 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!

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