Trello ID をタイムスタンプに変換する

このページは、プログラミングと Trello API の使用に関する多少の知識があることを前提としています。

API を使用せずにカードが作成された時間を調べる方法。

  1. カードを開く

  2. [共有] を選択します

  3. 日付と時刻は共有ウィンドウの下部に表示されます

以下の手順に従って、プログラムで Trello ID をタイムスタンプに変換します。

When customers are working with Trello data via the API or via the CSV or JSON export, we often get asked, "what's the dateCreated for the card/board?" There's not one, and while you can query the actions for the card and board and filter on createCard or createBoard actions, you're limited to the most recent 1000 actions using the API, which can be a problem for larger boards.

However, because the objects (cards, boards, lists) use MongoDB, the full ID for every object has additional information embedded in it (see ObjectID for full documentation), including the time it was created. Thus the first 8 characters of the hexadecimal id (the first 4 bytes) represent a Unix timestamp, which can then be translated into a date. Let's take a deeper look.

詳細な例

ステップ バイ ステップの詳細な例で説明して、次にコードの例をご紹介します。

Let's try to find when the Trello Development board was created, which has an id of:

4d5ea62fd76aa1136000000c

最初の 8 文字は次のようになります。

4d5ea62f

これを 16 進数から 10 進数に変換すると、タイムスタンプは次のようになります。

1298048559

This integer is a timestamp (Unix epoch) that represents the number of seconds that have elapsed since January 1, 1970 midnight UTC. It can be converted in most programming languages and sites like EpochConverter. Using the converter, we can see that this board was created on Fri, 18 Feb 2011 17:02:39 GMT. That was really early in Trello's development!

一部のプログラミング言語では、日付に変換する前にタイムスタンプをミリ秒単位にする必要があることにご注意ください。この場合、解析前に 1000 をかける必要があります。

Excel の例

オブジェクト ID が列 A1 にある場合は、次の数式を使用します。

=(((HEX2DEC(Left(A1,8))/60)/60)/24)+DATE(1970,1,1)

Javascript の例

idBoard = "4d5ea62fd76aa1136000000c"; new Date(1000*parseInt(idBoard.substring(0,8),16));

Python の例

import pytz from datetime import datetime id_board = "4d5ea62fd76aa1136000000c" creation_time = datetime.fromtimestamp(int(id_board[0:8],16)) utc_creation_time = pytz.utc.localize(creation_time)

R の例

cardID = "4d5ea62fd76aa1136000000c" timestamp = strtoi(strtrim(cardID, 8), 16L) dateCrceated = as.POSIXct(timestamp, origin = "1970-01-01")

PHP の例

<?php $cardID = '4d5ea62fd76aa1136000000c'; $createdDate = date('r', hexdec( substr( $cardID , 0, 8 ) ) ); echo $createdDate; ?>

 

さらにヘルプが必要ですか?

アトラシアン コミュニティをご利用ください。