PHP strtotime with date


PHP strtotime with date

strtotime provides unix timestamp which is nothing but integer representing seconds elapsed since 1 Jan 1970.

strtotime is like AI technology. If we pass something like "today", "tommorow", "next sunday", "10 hours" as argument, it gives output accordingly.
To convert unix timestamp to proper date we will use php date function.

date syntax : date(timestamp_format,unix timestamp);

timestamp_format: d: 0-31
m: 1-12
Y: 4 digit year

 <?php
 $date = strtotime("today");
 echo date("d/m/Y",$date);
 ?>

Output: 9/7/2022

To learn more about strtotime and date function you can visit: https://www.php.net/manual/en/function.strtotime.php
Kindly check out my youtube channel for tutorials on full stack web development and programming
https://www.youtube.com/channel/UCPaqaT2Lg-OzPMf-mUysArw