Graaljs: Timezone issue of graal node

Created on 5 Jan 2019  路  3Comments  路  Source: oracle/graaljs

I am in the GMT+8 timezone (Beijing).

When I use ordinary node:

new Date(Date.now()).toLocaleTimeString() //==>'8:38:48 PM'

However, when I use graal node:

new Date(Date.now()).toLocaleTimeString() //==>'4:38:48 AM'

Seems that graal node is using the GMT-8 timezone instead of my local timezone.

Node.js bug

Most helpful comment

Hi,

I think the timezone isn't the only problem. I'm getting the following result in Ubuntu 18.04:

$ ./bin/node -e 'console.log(new Date())' # GraalVM CE 19.1.1
2019-06-05T06:16:35.873Z
$ ./bin/node --jvm -e 'console.log(new Date())' # GraalVM CE 19.1.1
2019-08-11T20:09:58.280Z
$ node -e 'console.log(new Date())' # Node.js v12.8.0
2019-08-11T20:09:58.407Z

All 3 comments

Hi @lucifer1004

thanks for your request.

This is a limitation of the SubstrateVM image we build for our node executable. SVM currently does not allow to define the timezone at runtime (startup) of the image, but freezes that setting at image generation time already (to UTC, as you recognized). This is a known limitation and will be resolved in the future.

Note that it should work properly if you don't use the SubstrateVM image, i.e. if you start with node --jvm.

Best,
Christian

Hi,

I think the timezone isn't the only problem. I'm getting the following result in Ubuntu 18.04:

$ ./bin/node -e 'console.log(new Date())' # GraalVM CE 19.1.1
2019-06-05T06:16:35.873Z
$ ./bin/node --jvm -e 'console.log(new Date())' # GraalVM CE 19.1.1
2019-08-11T20:09:58.280Z
$ node -e 'console.log(new Date())' # Node.js v12.8.0
2019-08-11T20:09:58.407Z

I can confirm that there were various timezone-related issues in the past. Happily, the last issues (that I am aware of) were fixed recently and should be part of the upcoming GraalVM 20.1.0 release. When I try the preview of this release I get:

# GraalVM native mode
$ TZ=Asia/Shanghai node
> new Date(Date.now()).toLocaleTimeString()
'1:14:48 AM'

# GraalVM jvm mode
$ TZ=Asia/Shanghai node --jvm
> new Date(Date.now()).toLocaleTimeString()
'1:14:57 AM'

# Node.js
$ TZ=Asia/Shanghai node
> new Date(Date.now()).toLocaleTimeString()
'1:15:03 AM'

The same experiment with GraalVM 20.0.0 release shows the problem that you described. So, I am closing this issue. If you encounter any timezone or Date-related problem in GraalVM 20.1+ then let us know, please.

Was this page helpful?
0 / 5 - 0 ratings