Thursday, November 13, 2025
HomeLanguagesHow to convert a Date into Timestamp using PHP ?

How to convert a Date into Timestamp using PHP ?

The Task is to convert a Date to a timestamp using PHP. The task can be done by using the strtotime() function in PHP. It is used to convert English textual date-time description to a UNIX timestamp. The UNIX timestamp represents the number of seconds between a particular date and the Unix Epoch. 

Syntax:

strtotime ($EnglishDateTime, $time_now)

Example:  

PHP




// PHP program to convert the date 
// to timestamp 
<?php
  
$date = "2020-09-23";
$timestamp1 = strtotime($date);
echo $timestamp1
echo "<br>";
   
$date2 = "24-09-2020";
$timestamp2 = strtotime($date2);
echo $timestamp2
echo "<br>";
   
$date3 = "16 May 2019";
$timestamp3 = strtotime($date3);
echo $timestamp3;
?>
?>


Output:

1600819200
1600905600
1557964800
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11916 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11984 POSTS0 COMMENTS
Shaida Kate Naidoo
6889 POSTS0 COMMENTS
Ted Musemwa
7141 POSTS0 COMMENTS
Thapelo Manthata
6836 POSTS0 COMMENTS
Umr Jansen
6839 POSTS0 COMMENTS