Link to home
Start Free TrialLog in
Avatar of nickleplated
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.4000000-04:00 and need to be able to alert "registered 7 days ago".

Hope this makes sense. Points for urgency.

Thanks,
N
ASKER CERTIFIED SOLUTION
Avatar of netsmithcentral
netsmithcentral
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nickleplated
nickleplated

ASKER

Sweet - thank you kindly.

N
Quick question.

When I used "2007-07-25T15:09:32.4800000-04:00", I get -26 days ago... Seems the month is off by one?
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]);