当前位置 : 首页 » 编程语言 » 正文

js获取当月最后一天实例代码

分类 : 编程语言 | 发布时间 : 2018-04-21 09:06:21 | 浏览 : 0

以下就是JS代码::

@ author YHC:

复制代码 代码如下:

function getCurrentMonthLastDay(){
    var current=new Date();
    var currentMonth=current.getMonth();
    var nextMonth=++currentMonth;

    var nextMonthDayOne =new Date(current.getFullYear(),nextMonth,1);

    var minusDate=1000*60*60*24;

    return new Date(nextMonthDayOne.getTime()-minusDate);
  }
  function getCurrentMonthLastDay(){
     var current=new Date();
     var currentMonth=current.getMonth();
     var nextMonth=++currentMonth;

     var nextMonthDayOne =new Date(current.getFullYear(),nextMonth,1);

     var minusDate=1000*60*60*24;

     return new Date(nextMonthDayOne.getTime()-minusDate);
    }

复制代码 代码如下:

function getCurrentMonthFirstDay(){
    var current=new Date();
        current.setDate(1);
    return current;
   }
 function getCurrentMonthFirstDay(){
     var current=new Date();
         current.setDate(1);
     return current;
    }

相关阅读:

How to move an element into another element?

Set HTTP header for one request

Remove duplicates from an array of objects in JavaScript

Can I call jquery click() to follow an <a> link if I haven't bound an event handler to it with bind or click already?

Check whether a string matches a regex in JS

jQuery event to trigger action when a div is made visible

Check if user is using IE with jQuery

Resize HTML5 canvas to fit window

How do I replace a character at a particular index in JavaScript?

JavaScript file upload size validation