php

How to convert date to timestamp in PHP

In this tutorial, we are going to see how to convert date to timestamp in PHP. You can use the PHP strtotime() function to convert any textual date to a Unix timestamp. The following example will show you how it works.
 

How to convert date to timestamp in PHP
<?php
	$date1 = "15-07-2021";
	$timestamp1 = strtotime($date1);
	echo $timestamp1. '<br />'; 

	$date2 = "2021-07-15";
	$timestamp2 = strtotime($date2);
	echo $timestamp2. '<br />';

	$date3 = "15 July 2021";
	$timestamp3 = strtotime($date3);
	echo $timestamp3;
?>

Output:

1626321600
1626321600
1626321600

 
[st_adsense] mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *