# タイムゾーンの時差を直して、日本時間になるようにしたい

**URL:** <https://community.hubspot.com/t/topic/82954>\
**Category:** CRM\
**Created:** [June 8, 2023, 2:42pm UTC](https://community.hubspot.com/t/topic/82954 "2023-06-08T14:42:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yuki\_Tanaka](https://avatars.discourse-cdn.com/v4/letter/y/6f9a4e/32.png) [@Yuki\_Tanaka](https://community.hubspot.com/u/Yuki_Tanaka)\
**Post date:** [June 8, 2023, 2:42pm UTC](https://community.hubspot.com/t/topic/82954/1 "2023-06-08T14:42:29Z")

</div>

HubDB上で「掲載開始日時」と「掲載終了日時」を追加し、

その値によってコンテンツを表示、非表示を行いたいです。

コンテンツの表示、非表示自体はできたのですが、

タイムゾーンの設定の影響で、HubDBに入力した値と9時間の時差が生じてしまっています。

こちらのタイムゾーンを日本時間に自動で変換することは可能でしょうか？

```lia-code-sample
{% set localtime = local_dt|unixtimestamp %}
{% set table_query = "" %}
{% for row in hubdb_table_rows(5736966, table_query) %}
{% set start = to_local_time(row.start|unixtimestamp) %}
{% set end = to_local_time(row.end|unixtimestamp) %}

{% endfor %}

```

---

<div class="post-metadata">

**Author:** ![yskz\_aoyama](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/yskz_aoyama/32/32662_2.png) [@yskz\_aoyama](https://community.hubspot.com/u/yskz_aoyama)\
**Post date:** [June 9, 2023, 1:41am UTC](https://community.hubspot.com/t/topic/82954/2 "2023-06-09T01:41:21Z")

</div>

現状、HubDB 内の 日付 (Date) 型のデータはアカウント設定によらず UTC 時刻として扱われるようです。

簡単に日本時間として扱いたい場合は、

```lia-code-sample
{% set start = to_local_time(row.start|unixtimestamp - 32400000) %}
{% set end = to_local_time(row.end|unixtimestamp - 32400000) %}

```

のようにして、HubDB の値から 9 時間 (9 \* 60 \* 60 \* 1000 = 32400000 msec) 分を補正するのがいいかと思います。

いちいち補正せずに自動的になんとかしたいところですが、少し調べた限りでは方法が見当たりませんでした。

---

<div class="post-metadata">

**Author:** ![Yuki\_Tanaka](https://avatars.discourse-cdn.com/v4/letter/y/6f9a4e/32.png) [@Yuki\_Tanaka](https://community.hubspot.com/u/Yuki_Tanaka)\
**Post date:** [June 13, 2023, 8:40am UTC](https://community.hubspot.com/t/topic/82954/3 "2023-06-13T08:40:11Z")

</div>

ありがとうございます！

こちらで解決できました！
