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

How to convert date to unix timestamp in php

王林
王林Original
2021-02-22 16:44:282039browse

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);

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')

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!

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