nickleplated
asked on
Compare dates using ISO 8601 format.
I am being given a registration date in ISO 8601 format and need to get the difference between that date/time and current date and time.
I am being supplied 2007-07-22T15:59:53.400000 0-04:00 and need to be able to alert "registered 7 days ago".
Hope this makes sense. Points for urgency.
Thanks,
N
I am being supplied 2007-07-22T15:59:53.400000
Hope this makes sense. Points for urgency.
Thanks,
N
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Quick question.
When I used "2007-07-25T15:09:32.48000 00-04:00", I get -26 days ago... Seems the month is off by one?
When I used "2007-07-25T15:09:32.48000
It appears you are right. Sorry I didn't realize that before. Here's a devguru info page on date object months: http://www.devguru.com/technologies/javascript/10612.asp.
And to update the script change this:
var theDate = new Date(dateArr[0], dateArr[1], dateArr[2]);
To this:
var theDate = new Date(dateArr[0], parseInt(dateArr[1])-1, dateArr[2]);
And to update the script change this:
var theDate = new Date(dateArr[0], dateArr[1], dateArr[2]);
To this:
var theDate = new Date(dateArr[0], parseInt(dateArr[1])-1, dateArr[2]);
ASKER
N