0

Is there any recommendation of datetime calculation? I have been going toward UNIX timestamp and diff calculation method but both of it don't really provide a better way to complete my task.

Here is the sample of datetime I have. 2013-09-07 21:12

I wish to calculate the duration between the 2 datetime. Lastly display the total of minutes duration for the 2 datetime. Most of the calculation work to display for year, months, days, hours, minutes, seconds. I need some method to find out the duration between 2 times and convert the duration into total of minutes.

Anyone?

Carson Lee
  • 2,673
  • 3
  • 20
  • 23
  • How to get the difference between two dates has been asked numerous times and is easily found by using google or just searching this site. – John Conde Sep 07 '13 at 18:00

1 Answers1

0

Use function mktime to get the UNIX timestamp of the two dates, then take the bigger one and subtract the smaller one. You'll get another value, if you divide that value by 60, you'll get how many minutes are inbetween the two dates.

Kei
  • 771
  • 6
  • 17
  • You don't even need to identify the bigger and smaller, make use of abs(); but does OP want to allow for daylight savings? In which case unix timestamps won't help – Mark Baker Sep 07 '13 at 18:16