LoginSignup
2
0

More than 5 years have passed since last update.

TrelloAPIからタイムスタンプを取得する

Posted at

概要

TrelloAPIからリソース(ボード、カード、リストなど)が作成された日時(タイムスタンプ)を取得する方法について紹介します。

結論

Trelloの各リソース(一応Modelというらしい)のidは前半の8bitを16進数->10進数変換するとunixタイムスタンプで取得できます。

  • 通常の場合

function getTimeStamp(id) {
  let timeStamp16x = id.slice(0,8);
  let timeStamp = parseInt(timeStamp16x, 16);
  return timeStamp;
}
  • Moment.jsのmomentオブジェクトで取得する場合

//moment.jsで取得する場合
function getTimeStampMoment(id) {
  let timeStamp16x = id.slice(0,8);
  let timeStamp = parseInt(timeStamp16x, 16);
  let momentTimeStamp = moment.unix(timeStamp);
  return momentTimeStamp;
}
2
0
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
0