Thread: Date validation
View Single Post
  #2 (permalink)  
Old February 9th, 2004, 06:44 PM
Snib Snib is offline
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Code:
var dt = new Date(); //get the date

var day = dt.getDate(); //get the day

var month = dt.getMonth(); //get the month

var year = dt.getYear(); //get the year

//---------------------
//From here you will have some fancy comparisons between the saved date and the current date
//---------------------

//Example:

if(year >= old_year && month >= old_month && day >= old_date)alert("WHATEVER");
HOWEVER, the above comparison will not work. You will probably end up with a few ifs, and I seem to remember something about JavaScript's month being one behind, so January is 0, February is 1, etc.

Let me know if you need a better explanation.

HTH,

----------
---Snib---
----------
Reply With Quote