Skip to content

Instantly share code, notes, and snippets.

@yuily
Created January 24, 2015 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuily/b2d2ed015db476f1f442 to your computer and use it in GitHub Desktop.
Save yuily/b2d2ed015db476f1f442 to your computer and use it in GitHub Desktop.
【JavaScript】 日付を計算するプログラム
var dt = new Date();
var month = dt.getMonth()+1;
var day = dt.getDate();
var lastMonth = dt.setMonth(dt.getMonth() -1);
var lastmonth = dt.getMonth()+1;//このコードを忘れると、数字の羅列で表示される。
var twoMonths = dt.setMonth(dt.getMonth() -2);
var twomonth = dt.getMonth()+1;
@yuily
Copy link
Author

yuily commented Jan 24, 2015

JavaScriptで今日の日付から、1ヶ月前、2ヶ月前を計算するプログラムです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment