2
1

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 3 years have passed since last update.

Power Automate Desktop「UNIX時間のこと」

Posted at

概要

Power Automate DesktopでUNIX時間を日本標準時(JST)に変換します。某APIのドキュメントで見慣れない時間表記があったので調べました。下記のようなJSONで「1234567890」っていつのこと?Power Automate Desktopではどのように変換するんだという話です。

JSON
{
  "order": [
    {
      "key": "abcd",
      "orderdatetime": 1234567890,
      "dispatched": 1235431895
    },
    {
      "key": "abce",
      "orderdatetime": 1235531898,
      "dispatched": 1236895896
    }
  ]
}

環境

  • Windows 10Pro 21H1
  • Power Automate Desktop 2.13.163.21263

注意事項等

  • 2021年10月の情報です。
  • Windows 11の環境は持っていないので試していません。
  • 私が使用しているバージョンでの表記はPower Automate DesktopとなっているためPower Automate for Desktopにしていません。

UNIX時間のこと

ざっくりまとめると
UNIXエポック(協定世界時1970年1月1日午前0時0分0秒)から形式的な経過秒数で表した時刻表現とのこと。これならPower Automate Desktopのフロー内で変換できそうです。

フロー

2021-10-15-22-10-52.png

  1. 入力ダイアログを」表示
    変数名 %UnixTime%と設定
    2021-10-15-22-13-49.png

  2. Set variable

    変数名を %UnixBaseTimeJST%
    日本標準時(JST)は協定世界時(UTC) +9時間なので、UNIXエポック(協定世界時1970年1月1日午前0時0分0秒に9時間を足した値を宛先に設定します。
    %D'1970/01/01 09:00:00'%
    2021-10-15-22-14-30.png

  3. 加算する日時
    %UnixBaseTimeJST%に%UnixTime%を秒として加算します。
    2021-10-15-22-24-20.png

  4. メッセージを表示
    加算した日時の結果を表示して確認します。
    2021-10-15-22-27-07.png

PowerAutomateDesktop
Display.InputDialog Message: $'''Input UnixTime''' InputType: Display.InputType.SingleLine IsTopMost: False UserInput=> UnixTime ButtonPressed=> ButtonPressed
SET UnixBaseTimeJST TO D'1970/01/01 09:00:00'
DateTime.Add DateTime: UnixBaseTimeJST TimeToAdd: UnixTime TimeUnit: DateTime.TimeUnit.Seconds ResultedDate=> ResultedDateJST
Display.ShowMessage Message: ResultedDateJST Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed

まとめ

これだけです💦
UNIX時間「1234567890」のような表記がでてきても大丈夫そうです。
「1234567890」がいつなのかは試してください!
2038年問題なんてあるんですねw

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?