How to convert timestamp to date in php

王林
Release: 2023-03-03 06:56:01
Original
3540 people have browsed it

The way PHP converts timestamps into dates is through the date() function. The date() function can format a timestamp into a more readable date and time. The specific usage method is: [date('Y-m-s h:i:s',time());].

How to convert timestamp to date in php

Function introduction:

(Recommended tutorial: php tutorial)

PHP date() Function formats a timestamp into a more readable date and time.

Function syntax:

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

Parameter description:

  • ##format Required. Specifies the format of the timestamp.

  • #timestamp Optional. Specify timestamp. The default is the current date and time.

Code implementation:

<?php
var_dump(time()); //获取当前时间戳 int(1502245603)
$time = date(&#39;Y-m-s h:i:s&#39;,time());
Copy after login

The above is the detailed content of How to convert timestamp to date 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!