简体   繁体   中英

IBM Cloud Functions and Node.js: How to get Japan time?

I am writing a Node.js action in IBM Cloud Functions. How to get Japan time? I tried the following code at 6:28 AM Japan time but I got 9:28 PM.

Code:

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

Output:

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

I wonder if it was Sydney time because my namespace is in Sydney. However, It was 8:28 AM in Sydney, so I'm confusing.

没有第一个论点。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM