Zaloguj | Zarejestruj | FAQ
Anonymous

Lesson 11: JavaScript Objects - Date Object (Error for if)

+ Odpowiedz

Posty: 2 Strona 1 z 1


Lesson 11: JavaScript Objects - Date Object (Error for if)

przez aaron_tong » So maja 18, 2013 12:42 pm

//Create a Date object

var myDate = new Date();

//set the Date object to a specific date: 31 October, 2011

var mySetDate = myDate.setFullYear(2011, 9, 31);

//Create a second Date object

var now = new Date();

//Make the comparison: if the set date is bigger than today's date

Error(;) if (mySetDate > now);

{

//the set date is in the future

document.write("The 31st October is in the future");

}

//if the set date is smaller than today's date, it's in the past

else

{

document.write("The 31st October is in the past");

}
Avatar użytkownika

aaron_tong

  • Posty: 1
  • Dołączył(a): So maja 11, 2013 11:12 am

Re: Lesson 11: JavaScript Objects - Date Object (Error for i

przez XainPro » N maja 19, 2013 9:13 am

there was a small error it should be like this

Kod: Zaznacz cały

<html>
<head>
<title>title</title>
</head>
<body>
<script>
//Create a Date object

var myDate = new Date();

//set the Date object to a specific date: 31 October, 2011

var mySetDate = myDate.setFullYear(2011, 9, 31);

//Create a second Date object

var now = new Date();

//Make the comparison: if the set date is bigger than today's date

if (mySetDate > now)

{

//the set date is in the future

document.write("The 31st October is in the future");

}

//if the set date is smaller than today's date, it's in the past

else

{

document.write("The 31st October is in the past");

}
</script>
</body>
</html>

Avatar użytkownika

XainPro

  • Posty: 3933
  • Dołączył(a): Pt lut 17, 2012 8:10 pm


+ Odpowiedz

Strona 1 z 1