Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
24
rated 0 times [  26] [ 2]  / answers: 1 / hits: 59728  / 12 Years ago, tue, january 29, 2013, 12:00:00

I am using jQuery datepicker and tried to find out difference between todays date and selected date , but getting issues... rather than issues... I was not able to find it perfectly...



I tried to do this on 'onSelect event of datepicker '



Question:
How to check whether selected Date using jQuery Datepicjer is greater than 30 days from todays date ?



Any help will be appreciated....!!
note: dont want to use any libraries, I need to solve this by using only jQuery.


More From » jquery

 Answers
9

Get the timestamp for 30 days from now:



var timestamp = new Date().getTime() + (30 * 24 * 60 * 60 * 1000)
// day hour min sec msec


Compare that timestamp with the timestamp for the selected date.



if (timestamp > selectedTimestamp) {
// The selected time is less than 30 days from now
}
else if (timestamp < selectedTimestamp) {
// The selected time is more than 30 days from now
}
else {
// -Exact- same timestamps.
}

[#80556] Monday, January 28, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
andrea

Total Points: 445
Total Questions: 95
Total Answers: 103

Location: Tonga
Member since Tue, Nov 30, 2021
3 Years ago
;