Jump to content

First and Last day of cuurent month

Recommended Posts

Hello! Just wanted to share this simple JS code that I have used to show the First and Last day of the current month:


<p id="date1"></p>
<p id="date2"></p>

      var date = new Date();
      var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
      var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
      document.getElementById("date1").innerHTML = "First day = " + firstDay;
      document.getElementById("date2").innerHTML = "Last day = " + lastDay;



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...