This module is used to set and obtain the current system date, time, and time zone.
> **NOTE**<br>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The **systemTime** module provides system time and time zone features. You can use the APIs of this module to set and obtain the system time and time zone.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
| Promise<void> | Promise that returns no value.|
**Example**
```js
```js
// Set the system time to 2021-01-20 02:36:25.
vartime=1611081385000;
systemTime.setTime(time).then((data)=>{
console.log(`systemTime.setTime success data : `+JSON.stringify(data));
lettime=1611081385000;
systemTime.setTime(time).then(()=>{
console.log('Succeeded in setting systemTime.');
}).catch((error)=>{
console.error(`failed to systemTime.setTime because `+JSON.stringify(error));
console.error(`Failed to set systemTime. Cause:`+JSON.stringify(error));
});
```
```
## systemTime.getCurrentTime<sup>8+</sup>
...
...
@@ -90,23 +87,22 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| callback | AsyncCallback<number> | Yes| Callback used to return the time.|
| isNano | boolean | No | Whether the time to return is in nanoseconds.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
| callback | AsyncCallback<number> | Yes | Callback used to return the time elapsed since the Unix epoch. |
**Example**
```js
systemTime.getCurrentTime(true,(error,data)=>{
if(error){
console.error(`failed to systemTime.getCurrentTime because `+JSON.stringify(error));
return;
}
console.log(`systemTime.getCurrentTime success data : `+JSON.stringify(data));
});
```
```js
systemTime.getCurrentTime(true,(error,data)=>{
if(error){
console.error(`Failed to get systemTime. Cause:`+JSON.stringify(error));
return;
}
console.log(`Succeeded in getting systemTime.Data: `+JSON.stringify(data));
});
```
## systemTime.getCurrentTime<sup>8+</sup>
...
...
@@ -118,144 +114,139 @@ Obtains the time elapsed since the Unix epoch. This API uses a promise to return
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| callback | AsyncCallback<number> | Yes| Callback used to return the time.|
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| callback | AsyncCallback<number> | Yes| Callback used to return the time.|
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
> - The **<dialog>** component does not support the **focusable** and **click-effect** attributes.
> The **\<dialog>** component does not support the **focusable** and **click-effect** attributes.
## Styles
Only the **width**, **height**, **margin**, **margin-[left|top|right|bottom]**, and **margin-[start|end]** styles in [Universal Styles](js-components-common-styles.md) are supported.
Only the **width**, **height**, **margin**, **margin-[left|top|right|bottom]**, and **margin-[start|end]** styles in [Universal Styles](../arkui-js/js-components-common-styles.md) are supported.
## Events
Events in [Universal Events](js-components-common-events.md) are not supported. The following table lists the supported event.
## Events
The following events are supported. The [universal events](../arkui-js/js-components-common-events.md) are not supported.
| cancel | - | Triggered when a user taps a non-dialog area to cancel the pop-up. |
| show7+ | - | Triggered when the pop-up is displayed. |
| close7+ | - | Triggered when the pop-up is closed. |
## Methods
Methods in [Universal Methods](js-components-common-methods.md) are not supported. The following table lists the supported methods.
The following methods are supported. The [universal methods](../arkui-js/js-components-common-methods.md) are not supported.
| Name | Parameter | Description |
| ----- | ---- | ------ |
| show | - | Shows a dialog box.|
| close | - | Close the dialog box.|
| Name | Parameter | Description |
| ----- | --------- | -------------------- |
| show | - | Shows a dialog box. |
| close | - | Closes a dialog box. |
> **NOTE**
>
> Attributes and styles of a **\<dialog>** component cannot be dynamically updated.
> ![img](https://gitee.com/openharmony/docs/raw/master/en/application-dev/public_sys-resources/icon-note.gif) **NOTE:** Attributes and styles of a **\<dialog>** component cannot be dynamically updated.
## Example Code
## Example
```
```html
<!-- xxx.hml -->
<divclass="doc-page">
<divclass="btn-div">
...
...
@@ -73,6 +79,9 @@ Methods in [Universal Methods](js-components-common-methods.md) are not supporte
</div>
</dialog>
</div>
```
```css
/* xxx.css */
.doc-page{
flex-direction:column;
...
...
@@ -119,30 +128,33 @@ Methods in [Universal Methods](js-components-common-methods.md) are not supporte
| color | [ResourceColor](ts-types.md#resourcecolor) | No | Color.White | Font color. |
| fontSize | number \| string | No | 10 | Font size, in vp. |
| badgeSize | number \| string | No | 16 | Badge size, in vp. This parameter cannot be set in percentage. If it is set to an invalid value, the default value is used.|