Prizes & Awards
My Profile
Active Members
TodayLast 7 Days
more...
|
Javascript date object's getMonth()
This article explains date object's getMonth() method
getMonth()
returns current month code of current Date or month code of specified date.
<html>
<head>
<script>
function f()
{
var date = new Date ("August 21, 2006 01:15:00")
document.write(date.getMonth()+1)
}
</script>
</head>
<body>
<input type ="button" value ="Click to get month" onclick ="return f();" >
</body>
As get month returns an integer between 0 and 11, it will return 7 for August month In order to get correct results we increment it by 1 .We get output as 8.
|
|