---
sidebar_position: 0
---

# time

The `sos.management.time` API groups together methods for working with the system time.

<details>
    <summary>Time Management Capabilities</summary>
		| Capability | Description |
		|:------------|:-------------|
		| `SET_TIME` | If the device can set the system time. |
		| `SET_TIMEZONE` | If the device can set the system timezone. |
		| `GET_TIMEZONE` | If the device can get the system timezone. |
		| `NTP_TIME` | If the device can set the NTP server and system timezone. |

		If you want to check if the device supports those capabilities, use [`sos.management.supports()`](https://developers.signageos.io/sdk/sos_management/#supports).
</details>

## Methods

### get()

The `get()` method returns the currently set time from the device.

```ts expandable
get(): Promise<IGetTime>;
// show-more
interface IGetTime {
    currentDate: Date;
    timezone?: string;
    ntpServer?: string;
}

```

#### Return value

A promise that resolves to the current time with timezone.

#### Possible errors

If the time cannot be retrieved.

#### Example

```ts
const currentTime = await sos.management.time.get();
console.log(`Current time is: ${currentTime.currentDate} in timezone ${currentTime.timezone}`);
```

<Separator />

### setManual(dateTime, timezone)

The `setManual()` method sets the system time and the system timezone and disables NTP server settings.

:::warning Setting NTP server and timezone has side effects
- **Tizen**: After calling this API, display Reboots!
  Tizen has a limited set of available timezones. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405381271314-Tizen-Timezones-Limited-List-for-NTP).
- **RaspberryPi**: After calling this API, RPi Reboots the backend server, which can take up to 60 seconds! During the reboot, no JS API is
  available. **Always wait for Promise resolution.**
:::

```ts expandable
setManual(dateTime: DateTime, timezone: string): Promise<void>;
// show-more
interface DateTime {
    year: number;
    month: number;
    day: number;
    hour: number;
    minute: number;
    second: number;
}

```

#### Params

| Name       | Type       | Required         | Description               |
|------------|------------|------------------|---------------------------|
| `dateTime` | `DateTime` |  <div>Yes</div>  | The date and time to set. |
| `timezone` | `string`   |  <div>Yes</div>  | The timezone to set.      |

#### Return value

A promise that resolves when the time is successfully set.

#### Possible errors


- If `dateTime` is not a valid Date or DateTime object.
- If `timezone` is not a valid string.
- If the time cannot be set.

#### Example

```ts
// Set the system time to 2023-10-01T12:00:00 in Europe/Prague timezone
const dateTime = {
    year: 2023,
    month: 10,
    day: 1,
    hour: 12,
    minute: 0,
    second: 0,
}
await sos.management.time.setManual(dateTime, 'Europe/Prague');
```

<Separator />

### setNTP()

The `setNTP()` method sets the NTP server and the system timezone.

:::warning Setting NTP server and timezone has side effects
- **Tizen / WebOS**: After calling this API, display Reboots!
  Tizen has a limited set of available timezones. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405381271314-Tizen-Timezones-Limited-List-for-NTP).
- **RaspberryPi**: After calling this API, RPi Reboots the backend server, which can take up to 60 seconds! During the reboot, no JS API is
  available. **Always wait for Promise resolution.**
:::

```ts expandable
setNTP(ntpServer: string, timezone: string): Promise<void>;
```

#### Params

| Name        | Type     | Required         | Description            |
|-------------|----------|------------------|------------------------|
| `ntpServer` | `string` |  <div>Yes</div>  | The NTP server to set. |
| `timezone`  | `string` |  <div>Yes</div>  | The timezone to set.   |

#### Return value

A promise that resolves when the NTP server and timezone are successfully set.

#### Possible errors


- If `ntpServer` is not a valid string.
- If `timezone` is not a valid string.
- If the NTP server and timezone cannot be set.

#### Example

```ts
// Set the NTP server to `pool.ntp.org` and timezone to `Europe/Prague`
await sos.management.time.setNTP('pool.ntp.org', 'Europe/Prague');
```

<Separator />

### ~set()~

:::danger Deprecated

This method was deprecated. Use `setManual(dateTime, timezone)` instead.

:::

```ts expandable
set(currentDate: Date, timezone: string): Promise<void>;
```

<Separator />

### ~setManual(currentDate, timezone)~

:::danger Deprecated

This method was deprecated. Use `setManual(dateTime, timezone)` instead.

:::

```ts expandable
setManual(currentDate: Date, timezone: string): Promise<void>;
```

## API Example

```ts
import { sos } from '@signageos/front-applet';

void sos.onReady(async () => {
	const { currentDate, timezone, ntpServer } = await sos.management.time.get();
	console.log({ currentDate, timezone, ntpServer });

	// Set the time without a ntp server
	await sos.management.time.setManual(
		{
			year: 2025,
			month: 5,
			day: 23,
			hour: 13,
			minute: 0,
			second: 0,
		},
		'Europe/Amsterdam',
	);

	// Set the time with a ntp server
	await sos.management.time.setNTP('pool.ntp.org', 'Europe/Amsterdam');
});

```