Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to calculate the difference between two dates using PHP?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 95
    Comment on it
    Hello Readers If you want to calculate difference between two dates using PHP , use below code. comment: Suppose we have the two dates below date1 and date2
    $date1 = "2014-06-11";
    $date2 = "2015-07-16";
    comment:then we get diffrence with absolute value
    $diff = abs(strtotime($date2) - strtotime($date1));
    comment:then use the floor() function rounds a number DOWN to the nearest integer
    $years = floor($diff / (365606024));
    $months = floor(($diff - $years * 365606024) / (30606024));
    $days = floor(($diff - $years * 365606024 - $months30606024)/ (60*60*24));
    echo $years.'year'.$months.'month'.$days.'days';

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: