JavaScript Tutorial/Date/getFullYear

Материал из Web эксперт
Версия от 08:25, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Date().getFullYear()

The getFullYear() method returns the year in local time as a full four-digit number.



<html>
<head>
<title>Combine Date Values</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!--
var months = new Array(12);
months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";
var current_date = new Date();
month_value = current_date.getMonth();
day_value = current_date.getDate();
year_value = current_date.getFullYear();
document.write("The current date is " + months[month_value] + " " +
day_value + ", " + year_value);
//-->
</script>
</body>
</html>


Get Full year from current date

<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--
dateVar = new Date();
alert(dateVar.getFullYear());
//  -->
</script>
</head>
<body>
</body>
</html>