Skip to main content
Version: 6.5.3

Time

Management API time allows you to check your devices current time with a timezone and set current time with a timezone.

All methods

MethodDescriptionSupported since
get()Get current time settings4.0.0
setManual()Set manual datetime and timezone4.0.0
setNTP()Configure NTP server and timezone4.0.0
set()Set manual datetime and timezone (DEPRECATED)4.0.0

get()

Method get() lets you check for current time with time zone.

Javascript example

const time = await sos.management.time.get();

Example of response

When NTP is set:

{
"currentDate": Date("2019-04-01T01:11:11.111Z"),
"timezone": "Asia/Tokyo",
"ntpServer": "pool.ntp.org"
}

When NTP is not set:

{
"currentDate": Date("2019-04-01T01:11:11.111Z"),
"timezone": "Asia/Tokyo"
}

set()

Method set() lets you set manual time and timezone of the device.

warning

This method is deprecated. Use setManual() instead.

info

Calling set() will disable NTP server settings.

ParamTypeRequiredDescription
currentDateDate
Yes
Datetime to set
timezoneString
Yes
Timezone to set. Accepted values are timezone names from timezone database.

Javascript example

const currentDate = new Date();
const timezone = "Europe/Amsterdam";
await sos.management.time.set(currentDate, timezone);
warning

Setting time and timezone has side effects:

PlatformSide effect
TizenAfter calling this API, display Reboots!
webOSAfter calling this API, display Reboots!
RaspberryPiAfter calling this API, RPi Reboots backend server which can take up to 60 seconds!
During the reboot no JS API is available.
Always wait for Promise resolution.

setManual()

Method setManual() lets you set manual time and timezone of the device.

info

Calling setManual() will disable NTP server settings.

ParamTypeRequiredDescription
currentDateDate | object
Yes
Datetime to set
timezoneString
Yes
Timezone to set. Accepted values are timezone names from timezone database.

Javascript example

const datetimeObj = {
year: 2021,
month: 12,
day: 15,
hour: 9,
minute: 30,
seconds: 0,
};
const timezone = "Europe/Amsterdam";
await sos.management.time.setManual(datetimeObj, timezone);

// Using Date is deprecated. Use the example above.
const currentDate = new Date();
const timezone = "Europe/Amsterdam";
await sos.management.time.setManual(currentDate, timezone);
warning

Calling this method with currentDate as Date is deprecated. You should call it with datetime object instead. See example code.

warning

Setting time and timezone has side effects:

PlatformSide effect
TizenAfter calling this API, display Reboots!
webOSAfter calling this API, display Reboots!
RaspberryPiAfter calling this API, RPi Reboots backend server which can take up to 60 seconds!
During the reboot no JS API is available.
Always wait for Promise resolution.

setNTP()

Method setNTP() lets you configure NTP server and timezone.

ParamTypeRequiredDescription
ntpServerstring
Yes
Address of the NTP server
timezonestring
Yes
Timezone to set. Accepted values are timezone names from timezone database.

Javascript example

const ntpServer = "pool.ntp.org";
const timezone = "Europe/Amsterdam";
await sos.management.time.setNTP(ntpServer, timezone);
warning

Setting NTP server and timezone has side effects:

PlatformSide effect
TizenAfter calling this API, display Reboots!

Tizen has limited set of available timezones. Read more here.
RaspberryPiAfter calling this API, RPi Reboots backend server which can take up to 60 seconds!
During the reboot no JS API is available.
Always wait for Promise resolution.