9
6

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.

JSでUNIXのタイムスタンプを取得する

Posted at
const timeStamp = Math.round((new Date()).getTime() / 1000);

getTime()はUNIXエポックからミリ秒を返します。1000で割って秒表現を取得し、 Math.round()で値を整数に変換します。

日時(Tokyo)=2017/07/27 23:28:17

タイムスタンプ=1501165697

こちらのサイトでタイムスタンプを日付と時刻に変換できる。
http://url-c.com/tc/

9
6
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
9
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?