Can't get current local time in my timezone

If you are asking a question, please follow this template:

  1. My goal is: To get the current local time in my timezone(Philippines)
  2. My actions are: I have included SNTP library in mos.yml, and added sys.tz_spec in config, and invoked Timer.now() function.

heres my config.yml:

config_schema:
  - ["mqtt.server", "iot.eclipse.org:1883"]
  - ["i2c.enable", true]
  - ["sys.tz_spec", "s", "", {title: "See formats for the TZ env var: \"man tzset\". Formats like \":/path/to/file\" are not supported"}]

tags:
  - js

filesystem:
  - fs

libs:
  - origin: https://github.com/mongoose-os-libs/boards
  - origin: https://github.com/mongoose-os-libs/js-demo-bundle
  - origin: https://github.com/mongoose-os-libs/rpc-service-config
  - origin: https://github.com/mongoose-os-libs/rpc-service-fs
  - origin: https://github.com/mongoose-os-libs/rpc-uart
  - origin: https://github.com/mongoose-os-libs/wifi
  - origin: https://github.com/mongoose-os-libs/dht
  - origin: https://github.com/mongoose-os-libs/mjs
  - origin: https://github.com/mongoose-os-libs/sntp

heres my init.js code:

load('api_config.js');
load('api_rpc.js');
load('api_timer.js');
load('api_math.js');

Timer.set(2000 /* milliseconds */ , Timer.REPEAT, function() {
  let now = Timer.now();
  let s = Timer.fmt('%x %X:%p', now);
  print(s)
}, null);
  1. The result I see is: instead of my local timezon in ph, I got this
[Nov 10 11:21:30.351] 11/10/20 03:21:45:AM
[Nov 10 11:21:30.351] 11/10/20 03:21:45:AM
  1. My expectation & question is: How can I get my current local time in my timezone?? Iā€™m not sure about my sys.tz_spec config did I miss something?

Your tz_spec should be

- ["sys.tz_spec", "PST-8"]
1 Like

[RESOLVED]

It works now. I was able to get my current local tz. I just need to specify the tz_spec in my local timezone. Thanks again @nliviu