Home > Backend Development > PHP Problem > How to convert date to unix timestamp in php

How to convert date to unix timestamp in php

王林
Release: 2023-03-08 07:44:02
Original
2075 people have browsed it

How to convert date to unix timestamp in php: You can use strtotime function to convert date to unix timestamp, such as [strtotime('2021-01-24 08:15:42')].

How to convert date to unix timestamp in php

The operating environment of this article: windows10 system, php 7.3, thinkpad t480 computer.

Function introduction:

The strtotime() function parses any English text date or time description into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT).

Syntax:

strtotime(time,now);
Copy after login

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.

Convert date to UNIX timestamp

Example:


strtotime('2010-03-24 08:15:42')
Copy after login
Related recommendations:

php tutorial

The above is the detailed content of How to convert date to unix 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template