Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Date difference between two timezones in PHP

    • 0
    • 1
    • 1
    • 2
    • 0
    • 0
    • 0
    • 0
    • 605
    Comment on it

    Here is a short function to get the difference between two timezones in PHP:-

    1. function diff(){
    2. $date1 = "2014-02-27T20:00:00+04:00";
    3.  
    4. $date2 = "2014-02-28T07:20:00+08:00";
    5.  
    6. $diff = abs(strtotime($date2) - strtotime($date1));
    7. $years = floor($diff / (365*60*60*24));
    8. $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
    9. $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
    10. $hours = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
    11. $minuts = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
    12. $seconds = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minuts*60));
    13. printf("%d years, %d months, %d days, %d hours, %d minuts\n, %d seconds\n", $years, $months, $days, $hours, $minuts, $seconds);
    14.  
    15.  
    16. }
    17. diff();

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: