1# @ohos.enterprise.dateTimeManager 2 3The **dateTimeManager** module provides APIs for system time management, which can only be called by device administrator applications. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8 9## Modules to Import 10 11```js 12import dateTimeManager from '@ohos.enterprise.dateTimeManager' 13``` 14 15## dateTimeManager.setDateTime 16 17setDateTime(admin: Want, time: number, callback: AsyncCallback\<void>): void 18 19Sets the system time. This API uses an asynchronous callback to return the result. 20 21**Required permissions**: ohos.permission.ENTERPRISE_SET_DATETIME 22 23**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 24 25**System API**: This is a system API. 26 27**Parameters** 28 29| Name | Type | Mandatory | Description | 30| ----- | ----------------------------------- | ---- | ------- | 31| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.| 32| time | number | Yes| Timestamp (ms).| 33| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the setting is successful, **err** is **null**. Otherwise, **err** is an error object.| 34 35**Error codes** 36 37For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). 38 39| ID| Error Message | 40| ------- | ---------------------------------------------------------------------------- | 41| 9200001 | the application is not an administrator of the device. | 42| 9200002 | the administrator application does not have permission to manage the device. | 43 44**Example** 45 46```js 47let wantTemp = { 48 bundleName: "bundleName", 49 abilityName: "abilityName", 50}; 51dateTimeManager.setDateTime(wantTemp, 1526003846000, (error) => { 52 if (error) { 53 console.log("error code:" + error.code + " error message:" + error.message); 54 } 55}) 56``` 57 58## dateTimeManager.setDateTime 59 60setDateTime(admin: Want, time: number): Promise\<void> 61 62Sets the system time. This API uses a promise to return the result. 63 64**Required permissions**: ohos.permission.ENTERPRISE_SET_DATETIME 65 66**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 67 68**System API**: This is a system API. 69 70**Parameters** 71 72| Name | Type | Mandatory | Description | 73| ----- | ----------------------------------- | ---- | ------- | 74| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.| 75| time | number | Yes| Timestamp (ms).| 76 77**Return value** 78 79| Type | Description | 80| ----- | ----------------------------------- | 81| Promise\<void> | Promise that returns no value.| 82 83**Error codes** 84 85For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md). 86 87| ID| Error Message | 88| ------- | ---------------------------------------------------------------------------- | 89| 9200001 | the application is not an administrator of the device. | 90| 9200002 | the administrator application does not have permission to manage the device. | 91 92**Example** 93 94```js 95let wantTemp = { 96 bundleName: "bundleName", 97 abilityName: "abilityName", 98}; 99dateTimeManager.setDateTime(wantTemp, 1526003846000).then(() => { 100}).catch((error) => { 101 console.log("error code:" + error.code + " error message:" + error.message); 102}) 103``` 104