เพื่อหาวันที่แรกและวันสุดท้ายของเดือนปัจจุบันใน JavaScript สามารถลองรันโค้ดด้านล่างได้
<html>
<head>
<title>JavaScript Dates</title>
</head>
<body>
<script>
var date = new Date();
document.write("Current Date: " + date);
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
document.write("<br>" + firstDay);
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
document.write("<br>" + lastDay);
</script>
</body>
</html>