Home >Backend Development >PHP Problem >How to convert birthday to timestamp in php
How to convert birthday to timestamp in php: 1. Create a PHP sample file; 2. Check whether the birth date to be converted is around 1970; 3. Convert the birth date to a timestamp through the strtotime function. .
The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.
How to convert birthday to timestamp in php?
php Convert date of birth into timestamp
1. Sometimes we need to convert date of birth into timestamp
But people born before 1970 , when the date of birth is converted into a timestamp, the timestamp is a negative number; for people born after 1970, when the date of birth is converted into a timestamp, the timestamp is a positive number
Such as:
echo strtotime("1960-01-01");//结果:-315648000 echo strtotime("1984-01-01");//结果:441734400
However, it does not affect the display result of converting timestamp into date:
Such as:
echo date("Y-m-d",-315648000);//结果:1960-01-01 echo date("Y-m-d",441734400);//结果:1984-01-01
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to convert birthday to timestamp in php. For more information, please follow other related articles on the PHP Chinese website!