0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Pleasanterサーバースクリプトで日付データを別テーブル転記する時のズレ解消

0
Posted at

基本環境

Pleasanter 1.5.2.0

サーバースクリプトは日付データをUTCで取得

元テーブルmodel.DateA(JST)
編集画面ではJST
サーバースクリプトではUTCで取得
そのまま転記
転記先テーブルmodel.DateA(UTC)
9時間遅れとなる

対策スクリプト

DateAからDateAへ転記するようなスクリプトの場合、

let data = {
    Keys: ["Title"],
    Title: model.Title,
    DateHash: {
      DateA: model.DateA
    }
  };

UTCとして取得した日付データをJSTへ変換してから転記する

/ 日付データをUTCからJSTへ変換
  const date = model.DateA;
  const jstDate = date.toLocaleString("ja-JP",{ timeZone: "jst" });
  context.Log(date);
  context.Log(jstDate);
  
  let data = {
    Keys: ["Title"],
    Title: model.Title,
    DateHash: {
      DateA: jstDate
    }
  };

参考記事

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?