bjory Posted November 21, 2006 Share Posted November 21, 2006 Hi, I wannna calculate the difference in hours from 2 datetime strings e.g. [color=red]10/08/2006 11:00:00 [/color] and [color=red]10/02/2006 12:00:00[/color]. As these strings are varchars in the database, I hope someone can give me some clues how I can calculate the hours and min difference between these 2 strings.Thanks! Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted November 21, 2006 Share Posted November 21, 2006 [code]$time1 = strtotime("10/08/2006 11:00:00");$time2 = strtotime("10/02/2006 12:00:00");echo round(($time1 - $time2) / 86400, 2) . " Days Between Dates";[/code]Adjust the division (the 86400) for different time spans to get hours and so on. You could also break it out to days, hours, minutes, seconds by dividing and taking the remainder if you wanted. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.