Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lolicsystem/223481 to your computer and use it in GitHub Desktop.
Save lolicsystem/223481 to your computer and use it in GitHub Desktop.
JSで昨日の日付表す6桁の数値を得てみる
//
// 昨日の日付を表す6桁の数値を表示する
//
var uYear, uMon, uDate;
var nt = new Date();
nt.setTime(nt.getTime() - 86400000);
uYear = ("00" + (nt.getYear() - 100).toString()).slice(-2);
uMon = ("00" + (nt.getMonth() + 1).toString()).slice(-2);
uDate = ("00" + nt.getDate() .toString()).slice(-2);
var uYesterday = uYear + uMon + uDate;
alert(uYesterday);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment