JAVASCRIPT DATE


getTime() method in javascript

getTime method in javascript evaluates total number of milliseconds since January 1,1970.

Coding

<!DOCTYPE html>
<html>
<head>
<title>
JAVASCRIPT
</title>
</head>
<body>
<p id="dates">
</p>
<script>
var dt=new Date();
document.get.ElementById
("dates").innerHTML=
dt.getTime();
</script>
</body>
</html>

getFullYear method in javascript

getFullYear() method gets the present year in javascript.This function can be used to display present year in the web pages.

Coding

<!DOCTYPE html>
<html>
<head>
<title>
JAVASCRIPT
</title>
</head>
<body>
<p id="dates">
</p>
<script>
var dt=new Date();
document.get.ElementById
("dates").innerHTML=
dt.getFullYear();
</script>
</body>
</html>

getDay method in javascript

getDay() method in javascript is used to get present day.Remember that javascript counts weekdays starting from Sundays.Javascript counts sunday as 0 and saturday as 6.Hence there are days ranging from 0 to 6 not from 1 to 7 as usual.

Coding

<!DOCTYPE html>
<html>
<head>
<title>
JAVASCRIPT
</title>
</head>
<body>
<p id="dates">
</p>
<script>
var dt=new Date();
document.get.ElementById
("dates").innerHTML=
dt.getDay();
</script>
</body>
</html>

setFullYear method in javascript

setFullYear() method in javascript is used to set the date according to the developers choice.This function displays date in format as in below output.

Coding

<!DOCTYPE html>
<html>
<head>
<title>
JAVASCRIPT
</title>
</head>
<body>
<p id="dates">
</p>
<script>
var dt=new Date();
dt.setFullYear(2016,0,6);
document.getElementById
("dates").innerHTML=dt;
</script>
</body>
</html>