How to get timestamp in php

王林
Release: 2023-03-03 18:50:02
Original
5607 people have browsed it

How to obtain the timestamp in php: You can use the time() function or strtotime() function to obtain it. The time() function returns an integer containing the Unix timestamp of the current time. The strtotime() function parses any string datetime description into a Unix timestamp.

How to get timestamp in php

The time() function returns the number of seconds since the Unix epoch (January 1 1970 00:00:00 GMT) of the current time. Returns an integer containing the Unix timestamp of the current time.

(Recommended tutorial:php graphic tutorial)

Code implementation:

"); echo(date("Y-m-d",$t)); ?>
Copy after login

strtotime() function parses the date and time description of any string Is the Unix timestamp (number of seconds since January 1 1970 00:00:00 GMT).

Grammar:

int strtotime ( string $time [, int $now = time() ] )
Copy after login

(Video tutorial recommendation:php video tutorial)

Parameters:

  • ##time Required. Specifies a date/time string.

  • #now Optional. Specifies the timestamp used to calculate the return value. If this parameter is omitted, the current time is used.

Code implementation:


Copy after login

The above is the detailed content of How to get timestamp 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
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!