41
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

javascriptで月初、月末取得

Last updated at Posted at 2015-03-21

javascriptで月初、月末で取得するやり方
たいした内容ではないけど。。。
メモとして残しておく

月初

var date = new Date();
date .setDate(1);

月末

var date = new Date();
date.setDate(1);//ここ大事
date.setMonth(date.getMonth() + 1);
date.setDate(0);

setDateは0を指定するの前月の最終日になる。
最近知った。。。

41
24
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
41
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?