Skip to content

Setting Environment variable TZ does not affect Date.getTimezoneOffset() #6091

Open
@jpravetz

Description

@jpravetz

Datetime timezoneoffset has not been implemented?

Run this script with deno (can use process.env.TZ or Deno.env.set method):

import process from 'node:process';
const now = new Date();
console.log(now.getTimezoneOffset(), 'default');
['America/Costa_Rica', 'EST', 'America/St_Johns', 'UTC', 'America/Vancouver', 'Australia/Adelaide'].forEach(
  (tz) => {
    process.env.TZ = tz;
    console.log(now.getTimezoneOffset(), tz);
  }
);

Actual output:

360 default
360 America/Costa_Rica
360 EST
360 America/St_Johns
360 UTC
360 America/Vancouver
360 Australia/Adelaide

Then run this with node:

const process = require('node:process');
const now = new Date();
console.log(now.getTimezoneOffset(), 'default');
['America/Costa_Rica', 'EST', 'America/St_Johns', 'UTC', 'America/Vancouver', 'Australia/Adelaide'].forEach(
  (tz) => {
    process.env.TZ = tz;
    console.log(now.getTimezoneOffset(), tz);
  }
);
360 default
360 America/Costa_Rica
300 EST
150 America/St_Johns
0 UTC
420 America/Vancouver
-570 Australia/Adelaide

Looks like feature not implemented?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions