1# TimeService 2 3 4## Overview 5 6Enables the application to obtain the time and time zone information. 7 8**Since**: 12 9 10 11## Summary 12 13 14### File 15 16| Name| Description| 17| -------- | -------- | 18| [time_service.h](time__service_8h.md) | Declares the API for obtaining the time and time zone information. | 19 20 21### Types 22 23| Name| Description| 24| -------- | -------- | 25| typedef enum [TimeService_ErrCode](#timeservice_errcode)[TimeService_ErrCode](#timeservice_errcode) | Enumerates the error codes.| 26 27 28### Enums 29 30| Name| Description| 31| -------- | -------- | 32| [TimeService_ErrCode](#timeservice_errcode) {<br>TIMESERVICE_ERR_OK = 0,<br>TIMESERVICE_ERR_INTERNAL_ERROR = 13000001,<br>TIMESERVICE_ERR_INVALID_PARAMETER = 13000002<br>} | Enumerates the error codes.| 33 34 35### Functions 36 37| Name| Description| 38| -------- | -------- | 39| [TimeService_ErrCode](#timeservice_errcode)[OH_TimeService_GetTimeZone](#oh_timeservice_gettimezone) (char \*timeZone, uint32_t len) | Returns the current system time zone. | 40 41 42## Type Description 43 44 45### TimeService_ErrCode 46 47``` 48typedef enum TimeService_ErrCode TimeService_ErrCode 49``` 50 51**Description** 52 53Enumerates the error codes. 54 55**Since**: 12 56 57 58## Enum Description 59 60 61### TimeService_ErrCode 62 63``` 64enum TimeService_ErrCode 65``` 66 67**Description** 68 69Enumerates the error codes. 70 71**Since**: 12 72 73| Value| Description| 74| -------- | -------- | 75| TIMESERVICE_ERR_OK | Obtains system parameters.| 76| TIMESERVICE_ERR_INTERNAL_ERROR | Fails to obtain system parameters.| 77| TIMESERVICE_ERR_INVALID_PARAMETER | Invalid parameter.| 78 79 80## Function Description 81 82 83### OH_TimeService_GetTimeZone() 84 85``` 86TimeService_ErrCode OH_TimeService_GetTimeZone (char * timeZone, uint32_t len ) 87``` 88 89**Description** 90 91Returns the current system time zone. 92 93**System capability**: SystemCapability.MiscServices.Time 94 95**Since**: 12 96 97**Parameters** 98 99| Name| Description| 100| -------- | -------- | 101| timeZone | A character array of time zone ID. If the time zone is obtained, the time zone ID string of the current system is written. Otherwise, an empty string is written. The string ends with **\0**. | 102| len | Length of a character array of time zone ID without maximum limit. You are advised to apply for sufficient memory for at less 31 bytes. | 103 104**Returns** 105 106**TIMESERVICE_ERR_OK**: The system parameters are obtained. 107 108**TIMESERVICE_ERR_INTERNAL_ERROR**: The system parameters fail to be obtained. 109 110**TIMESERVICE_ERR_INVALID_PARAMETER**: The time zone is null or the length of the time zone name (excluding the end character **\0**) is greater than or equal to **len**.