- Mark as New
- Follow
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
In essence time in javascript is stored as a long (just like in java) this means that increasing this number by 1000 increases the date by 1second.
We know that 1 day = 24 hours = 1440 mins = 86400 seconds (*1000 for ms)
So what you need to do is calculate the number of days you have during those months and multiply this by 86400000 and add this to the date.
I would also suggest calculating the max time (date + 6months) up in front, if the user specifies a higher date (userdate - currentdate > date_in_6_months), it's actually invalid and you could just replace the userinput by your calculation. This way the end-user is never able to store a date further in time and your validation is already done. You could also try replacing when user_date < current_date, but thats up to you, i don't know your business-logic.
If possible try to provide this data using XML binding, this way you could do the calculations in java/.net or whatever programming lanague you use. JavaScript is one of the most horrible environments to work with dates. It's just a hint.
Views
Replies
Total Likes