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

toISOStringから時間を整形する。

Last updated at Posted at 2018-02-27

toISOStringはブラウザによる整形誤差が少ない。

new Date().toISOString()
//"2018-02-27T05:39:34.596Z"

9時間分足す。Zは世界協定時を示すので、削る。

  function time(){
    return new Date(Date.now()+1000*60*60*9)
      .toISOString()
      .replace(/-/g,'/')
      .replace('T',' ')
      .slice(0,'YYYY/MM/DD hh:mm'.length)
    ;
  }
time();//"2018/02/27 14:32"
2
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
2
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?