4
4

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のDateオブジェクトをStringのXXXX-XX-XXに変換する

Posted at

/*
* Convert Javascript Date Object to String XXXX-XX-XX
*/
function getStringDate(aDate){
var dd = aDate;
var yy = dd.getYear();
var mm = dd.getMonth() + 1;
dd = dd.getDate();
if (yy < 2000) { yy += 1900; }
if (mm < 10) { mm = "0" + mm; }
if (dd < 10) { dd = "0" + dd; }
var rs = yy + "-" + mm + "-" + dd;
return rs;
}

4
4
0

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
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?