【问题标题】:IBM Cloud Functions and Node.js: How to get Japan time?IBM Cloud Functions 和 Node.js:如何获取日本时间?
【发布时间】:2021-12-01 11:11:06
【问题描述】:

我正在 IBM Cloud Functions 中编写一个 Node.js 操作。如何获得日本时间?我在日本时间上午 6 点 28 分尝试了以下代码,但我得到了晚上 9 点 28 分。

代码:

console.log(new Date().toLocaleString({ timeZone: 'Asia/Tokyo' }))

输出:

"2021-10-12T21:28:43.740984Z    stdout: 10/12/2021, 9:28:43 PM"

我想知道是不是悉尼时间,因为我的命名空间在悉尼。但是,悉尼的时间是上午 8 点 28 分,所以我很困惑。

【问题讨论】:

  • 您能否为您的问题添加更多详细信息?打印的时间会与 UTC 匹配吗?
  • 哦,没错。这是UTC。感谢您的评论,我发现了一个错误。

标签: node.js ibm-cloud ibm-cloud-functions


【解决方案1】:

没有第一个参数。

console.log(new Date().toLocaleString('ja-JP', { timeZone: 'Asia/Tokyo' }))

【讨论】:

    猜你喜欢
    • 2021-04-28
    • 1970-01-01
    • 2021-02-24
    • 2021-05-03
    • 2017-09-19
    • 2021-04-23
    • 2019-01-24
    • 2021-06-05
    • 2019-10-15
    相关资源
    最近更新 更多