Author Topic: Difference between two times with getDateTime? Or how to convert to timestamp?  (Read 495 times)

I have dates that are in the format getDateTime gives.
How can I find out how far these are from the current getDateTime value?

It seems to be in plain text (04/11/12 16:13:26) so shouldn't basic math work? I guess you should classify each set of numbers as date, month, year, etc. but that shouldn't be too hard?
« Last Edit: April 11, 2012, 09:40:58 AM by Demian »

It seems to be in plain text (04/11/12 16:13:26) so shouldn't basic math work?I guess you should classify each set of numbers as date, month, year, etc. but that shouldn't be too hard?
I was origionally just gonna get the date by having some code that subStringed the area between the two slashes, and then compare those.
But then I realized it'd get a lot more complicated, adding in months, accounting for the fact each month has a different amount of days, adding in years, leap years, etc.
So I figured there was probably a prebuilt function somewhere I could use.

Well how accurate does it need to be? You could very easily get an output that says "2 months, 6 days, 10 hours, 21 minutes, 34 seconds", but you don't know whether the month is February or not.

Besides, I personally doubt that there is a prebuilt function, you might as well start working on one of your own.

Well how accurate does it need to be? You could very easily get an output that says "2 months, 6 days, 10 hours, 21 minutes, 34 seconds", but you don't know whether the month is February or not.

Besides, I personally doubt that there is a prebuilt function, you might as well start working on one of your own.
It'd be easist if I got it in a difference of seconds, then I could be like
if(timeDiffFunc(%oldtime,getDateTime()) > 60*60*24*7)