Possible Duplicate:
JavaScript date objects UK dates
I have the following code and I am having problem setting the date format to british i.e
var birthday = new Date("20/9/1988");
when I run the code I get You are NaN years old
. error but If i change it to say 09/20.1988 it works
var birthday = new Date("20/9/1988");
var today = new Date();
var years = today.getFullYear() - birthday.getFullYear();
// Reset birthday to the current year.
birthday.setFullYear(today.getFullYear());
// If the user's birthday has not occurred yet this year, subtract 1.
if (today < birthday)
{
years--;
}
document.write("You are " + years + " years old.");
// Output: You are years years old.