Javascript Date Methods
The javascript date methods are two types there are ;
1 . Get Method
2. Set Method  
Get Methods :
Method Description
getDate() Get the numeric day (1 - 31) of the specified date.
getDay() Get the day of the week (0 - 6) for the specified date.
getFullYear() Get the four digit year(yyyy) of the specified date.
getHours() Get the hour (0 - 23) in the specified date.
getMilliseconds() Get the milliseconds (0 - 999) in the specified date.
getMinutes() Get the minutes (0 - 59) in the specified date.
getMonth() Get the month (0 - 11) in the specified date.
getSeconds() Get the seconds (0 - 59) in the specified date.
getTime() Get the milliseconds as number since January 1, 1970, 00:00:00 UTC.
Example :
<html>
<head>
<title>Javascript Date Methods</title>
</head>
<body>
 
<script type="text/javascript">
 
var date = new Date("December 01, 1991 04:30:00");
 
//getDate() method
document.write("getDate() : " + date.getDate() );
document.write("<br /><br />"); 
 
//getDay() method
document.write("getDay() : " + date.getDay() );
document.write("<br /><br />"); 
 
//getFullYear() method
document.write("getFullYear() : " + date.getFullYear() );
document.write("<br /><br />");
 
//getHours() method
document.write("getHours() : " + date.getHours() );
document.write("<br /><br />");
 
//getMilliseconds() method
var date_1 = new Date( );
document.write("getMilliseconds() : " + date_1.getMilliseconds() );
document.write("<br /><br />");
 
//getHgetMinutesours() method
document.write("getMinutes() : " + date.getMinutes() ); 
document.write("<br /><br />");
 
//getMonth() method
document.write("getMonth() : " + date.getMonth() ); 
document.write("<br /><br />");
 
//getSeconds() method
document.write("getSeconds() : " + date.getSeconds() );
document.write("<br /><br />");
 
//getTime() method
document.write("getTime() : " + date.getTime() );
document.write("<br /><br />");
 
</script>
 
</body>
</html>
Output :
Set Methods :
Method Description
setDate() Set the day as a number (1-31)
setFullYear() Sets the four digit full year as number in the date object.
setHours() Sets the hours as number in the date object.
setMilliseconds() Sets the milliseconds as number in the date object.
setMinutes() Sets the minutes as number in the date object.
setMonth() Sets the month as number in the date object.
setSeconds() Sets the seconds as number in the date object.
setTime() Sets the time as number in the Date object since January 1, 1970, 00:00:00 UTC.
Example :
<html>
<head>
<title>Javascript Date Set Methods</title>
</head>
<body>
 
<script type="text/javascript">
 
var date = new Date("December 01, 1991 04:30:00");
 
//setDate() method
date.setDate( 24 );
document.write( date );
document.write("<br /><br />"); 
 
//setFullYear() method
date.setFullYear( 2017 );
 document.write( date );
document.write("<br /><br />"); 
 
//setHours() method
date.setHours( 06 );
document.write( date ); 
document.write("<br /><br />");
 
//setMilliseconds() method
date.setMilliseconds( 960 );
document.write( date );
document.write("<br /><br />");
 
//setMinutes() method
date.setMinutes( 45 );
document.write( date );
document.write("<br /><br />");
 
//setMonth() method
date.setMonth( 6 );
document.write( date );
document.write("<br /><br />");
 
//setSeconds() method
date.setSeconds( 90 );
document.write( date );
document.write("<br /><br />");
 
//setTime() method
date.setTime( 8698000 );
document.write( date );
document.write("<br /><br />");
 
</script>
 
</body>
</html>
Output :

We see you’re using an ad blocker.

Our website is made possible by displaying ads to our visitors.

Please help us continue to provide you with free. So please disabling your ad blocker.