• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
seegatesite header

Seegatesite.com

Seegatesite.com - Programming Tutorial , Sharing , How and Learn Together

  • TOOLS
    • Bootstrap Navbar Online Generator
    • Customize Sidebar Menu Bootstrap 3
    • Bootstrap Demo
  • ADVERTISE
  • CATEGORIES
    • Android
    • Blogging Tips
    • Database
    • CSS
    • Info Gadget
    • Javascript
    • Linux
    • PHP
    • Various
    • WordPress
  • Q&A
  • PHP
  • JAVASCRIPT
  • JQUERY
  • ANGULAR
  • WORDPRESS
  • SEO
  • REACT
🏠 » Javascript » Tutorial Create First And Last Day Of The Current Month Javascript

Tutorial Create First And Last Day Of The Current Month Javascript

By Sigit Prasetya Nugroho ∙ April 25, 2019 ∙ Javascript ∙ Leave a Comment

Share : TwitterFacebookTelegramWhatsapp

An easy way to display the first day and the last day of the current month using javascript. The date is an important component of an application. Usually, information system applications require dates to carry out business processes. Moreover, to display a reporting period, it requires an input date. Usually, programmers provide the first day and the last day of the month as the initial date input display. I will share the javascript function to display the first day and the last day of the current month. Check out the following tutorial

Javascript function gets the first day and the last day of the current month

How To Get First Dayand The Last Day Of Current Month Javascript Min

Copy the following code and apply it to your application

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function firstDateOfMonth(){
var date = new Date();
                var y = date.getFullYear();
                var m = date.getMonth();
var firstDay = new Date(y, m, 1);
return firstDay;
}
 
function firstDateOfYearMonth(y,m){
var firstDay = new Date(y, m-1, 1);
return firstDay;
}
 
 
 
function lastDateOfMonth(){
var date = new Date();
                var y = date.getFullYear();
                var m = date.getMonth();
var lastDay = new Date(y, m + 1, 0);
return lastDay;
 
}
 
function lastDateOfYearMonth(y,m){
var lastDay = new Date(y, m, 0);
return lastDay;
 
}
 
function format_date(d){
                var month = '' + (d.getMonth() + 1);
                var day = '' + d.getDate();
                var year = d.getFullYear();
                if(month.length < 2){
                    month = '0' + month;
                }
                if(day.length < 2){
                    day = '0' + day;
                }
                return [day, month, year].join('/');
}

Please try the following example to apply the function of getting the first and the last day of a particular month javascript

Other Article : How To Load JSON Data From Rest API To Select2 JQuery Plugin

Demo : How to get first and the last day of current month javascript

The format_date(d) is used to change the date format. You can change the format_date function according to your application needs.

In Example How to Format Javascript Date To Mysql Format Date

1
2
3
4
5
6
7
8
9
10
function format_date(d){
  month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
 
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
 
return [year, month, day ].join('-');
}

Thus my short tutorial on how to display the first day and the last day of the month in javascript

Another Javascript Related Post :

  • React-Table Not Updating or Refreshing Data, The Solution ?
  • How To Custom React Datepicker In Bootstrap
  • Tutorial Create Simple POS Using ReactJS And Laravel Lumen Part 1
  • Adept Using Datatables Plugin In 10 Minutes For Beginners (Tutorial)
  • The Using Of Reactstrap And React-Table, Suitable For Beginners
  • Tutorial Create Simple Block UI Using React JS

Avatar for Sigit Prasetya Nugroho

About Sigit Prasetya Nugroho

This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Welcome to my Home,

Avatar for Sigit Prasetya NugrohoThis site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.



Popular Articles

Checked checkbox AdminLTE Bootstrap in Jquery

November 4, 2014 By Sigit Prasetya Nugroho 7 Comments

Simple create date format validation with jqueryUI

December 21, 2014 By Sigit Prasetya Nugroho Leave a Comment

Create Simple Progress Bar for Fake Online Generator with Jquery

January 10, 2015 By Sigit Prasetya Nugroho Leave a Comment

22+ Coolest Free Jquery Plugin For Premium Theme

October 3, 2015 By Sigit Prasetya Nugroho Leave a Comment

Easy Build Your Anti Copy Paste Plugin

October 6, 2015 By Sigit Prasetya Nugroho Leave a Comment

Popular Tags

adminlte (15) adsense (13) adsense tips (4) affiliate amazon (13) amazon (12) Android (8) angular (16) angular 4 (12) angular 5 (4) asin grabber (3) Bootstrap (27) codeigniter (5) create wordpress theme (5) crud (8) css (6) free wordpress theme (7) google adsense (4) imacros (4) increase traffic (6) jquery (34) laravel (10) laravel 5 (5) learn android (5) lumen api (4) modal dialog (5) mysql (6) nodeJs (4) optimize seo (4) pdo (6) php (30) plugin (53) pos (8) Publisher Tips (5) react (6) Reactjs (9) SEO (37) theme (17) tutorial angular (5) tutorial angular 4 (6) tutorial javascript (10) tutorial javascript beginners (4) twitter (3) wordpress (18) wordpress plugin (13) XMLRPC (5)




  • About
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

©2022 Seegatesite.com