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

How to convert timestamp to hour format in php

王林
Release: 2023-03-06 06:40:01
Original
3527 people have browsed it

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
Copy after login

Description: The

date() function can format the timestamp into a more readable date and time.

Syntax:

date ( string $format [, int $timestamp ] )
Copy after login

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

Output result:

2016/10/21
2016.10.21
2016-10-21
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template