Ngày đầu tháng: new Date(year, month, 1). Ngày cuối tháng: new Date(year, month + 1, 0) (ngày 0 của tháng sau là ngày cuối tháng hiện tại).
Ví dụ
<html>
<head>
<title>Ngày đầu cuối tháng trong JavaScript</title>
</head>
<body>
<script>
var date = new Date();
document.write("Ngày hiện tại: " + date + "<br>");
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
document.write("Ngày đầu tháng: " + firstDay + "<br>");
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
document.write("Ngày cuối tháng: " + lastDay);
</script>
</body>
</html>