LoginSignup
1
2

More than 5 years have passed since last update.

[JavaScript] 外部ライブラリなし拙速日付書式(年4桁、月2桁、日2桁)

Posted at

外部ライブラリなしで、とにかく拙速に日付を書式化しようというだけです。

年4桁、月と日は0パディングして2桁にします。

var formatDate = function(d) {
    return ''
        + d.getFullYear()
        + ('0' + (d.getMonth() + 1)).substr(-2, 2)
        + ('0' + d.getDate()).substr(-2, 2);
};

こういう簡単すぎるネタは如何なものかと考えるプライドを振り切っての投稿です。
(言い訳がましい)

1
2
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
1
2