| Blockland Forums > Modification Help |
| Difference between two times with getDateTime? Or how to convert to timestamp? |
| (1/1) |
| DrenDran:
I have dates that are in the format getDateTime gives. How can I find out how far these are from the current getDateTime value? |
| 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? |
| DrenDran:
--- Quote from: Demian on April 11, 2012, 09:11:37 AM ---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? --- End quote --- 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. |
| Treynolds416:
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. |
| DrenDran:
--- Quote from: Treynolds416 on April 11, 2012, 06:22:36 PM ---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. --- End quote --- 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) |
| Navigation |
| Message Index |