get time difference in php
Date and time is one function which is always like there in whatever website, project you create. The more simple they look like to start with the more complex they become. Complexity comes in when we put these functions into different loops conditions etc. The line below show you how you can call function. The function expects to be given 2 strings representing the start and end values of a time or date. <?php echo 'Hi! My name is Ankit Kumar Chauhan. I am: '.getDifference(date("Y-m-d G:i:s"),'1985-10-02 00:00:00'). ' Years old.'; function getDifference($startDate,$endDate,$format = 6) { list($date,$time) = explode(' ',$endDate); $startdate = explode("-",$date); $starttime = explode(":",$time); list($date,$time) = explode(' ',$startDate); $enddate = explode("-",$date); $endtime = explode(":",$time); $secondsDifference = mktime(...