$d1=mktime(22,0,0,1,1,2007);
$d2=mktime(0,0,0,1,2,2007);
echo "Hours difference = ".floor(($d2-$d1)/3600) . "<br>";
echo "Minutes difference = ".floor(($d2-$d1)/60) . "<br>";
echo "Seconds difference = " .($d2-$d1). "<br>";
echo "Month difference = ".floor(($d2-$d1)/2628000) . "<br>";
echo "Days difference = ".floor(($d2-$d1)/86400) . "<br>";
echo "Year difference = ".floor(($d2-$d1)/31536000) . "<br>";
mktime() : create the timestamp using date and time
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.
Sashi | 20-03-2010 |
Thanks for providing this simple and efficient date difference check functionality. It works ! |
Sadart Abukari | 09-07-2011 |
Great article for all my data manipulation needs. Implemented it with sessions using explode() to turn time stored in session as string and passed it to call_user_func_array with mktime and the exploded array as parameters. Thanks a bunch. |
sriram | 25-07-2014 |
nice code |
Riddhish | 09-04-2015 |
Really Helpfull |