435,434 Members | 2,963 Online
Need help? Post your question and get tips & solutions from a community of 435,434 IT Pros & Developers. It's quick & easy.

# Calculating the difference

 P: n/a Hej dudes, I need to calc the difference between two timestamps / dates ... For example what i need to calculate: Date 1: 2007.11.06 - 20:13:04 Date 2: 2007.11.07 - 21:13:04 Difference: 1 day, 1hour Very simple in php .. but how do i calculate the difference between the following values: Date 1: 2007.11.06 - 20:13:04 Date 2: 2007.11.08 - 03:13:04 Does someone have a quick solution for this ? Thanks ahead ... Oct 1 '07 #1
5 Replies

 P: n/a Julius wrote: Hej dudes, I need to calc the difference between two timestamps / dates ... For example what i need to calculate: Date 1: 2007.11.06 - 20:13:04 Date 2: 2007.11.07 - 21:13:04 Difference: 1 day, 1hour Very simple in php .. Very simple? > but how do i calculate the difference between the following values: Date 1: 2007.11.06 - 20:13:04 Date 2: 2007.11.08 - 03:13:04 Does someone have a quick solution for this ? Thanks ahead ... Why is the first simple and the second hard? Anyway: go to www.php.net and look up: strtotime Then use the difference in time to calculate the elapsed . Beware of timezone offset stuff. If it is not in the original date, don't worry. Regards, Erwin Moller Oct 1 '07 #2

 P: n/a On 1 Oct, 14:49, Julius

 P: n/a "Julius"

 P: n/a "Steve" "Julius" Hej dudes,I need to calc the difference between two timestamps / dates ...For example what i need to calculate:Date 1: 2007.11.06 - 20:13:04Date 2: 2007.11.07 - 21:13:04Difference: 1 day, 1hourVery simple in php ..but how do i calculate the difference between the following values:Date 1: 2007.11.06 - 20:13:04Date 2: 2007.11.08 - 03:13:04 sorry, didn't take you oddball date notation as a single date stamp but as the calculation. anyway, bruno's works fine. Oct 1 '07 #5

 P: n/a On 1 Oct, 15:24, "Steve" [/PHP] I removed the 1970 because that was the default value, so if the distance is 0 years, then it will show up as 1970 - 1970 which is 0. Also, in \$time_fix, you can edit the number of seconds to remove from the difference, so if you don't need to remove 3600 or whatever, you can edit that easily. Oct 1 '07 #6

### This discussion thread is closed

Replies have been disabled for this discussion.