Add user defined function method to Date object
<html>
<head>
<script type="text/javascript">
Date.prototype.getActualMonth = getActualMonth;
function getActualMonth() {
var n = this.getMonth();
n += 1;
return n;
}
</script>
</head>
<body>
<script type="text/javascript">
var today = new Date();
alert(today.getActualMonth());
</script>
</body>
</html>
Related examples in the same category