js-apis-system-time.md 17.3 KB
Newer Older
E
ester.zhou 已提交
1
# System Time and Time Zone
Z
zengyawen 已提交
2

E
ester.zhou 已提交
3
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.
Z
zengyawen 已提交
4

E
ester.zhou 已提交
5
> **NOTE**
E
ester.zhou 已提交
6
>
E
ester.zhou 已提交
7
> 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.
Z
zengyawen 已提交
8

W
wusongqing 已提交
9
## Modules to Import
Z
zengyawen 已提交
10

E
ester.zhou 已提交
11
```js
Z
zengyawen 已提交
12 13 14
import systemTime from '@ohos.systemTime';
```

W
wusongqing 已提交
15
## systemTime.setTime
Z
zengyawen 已提交
16

W
wusongqing 已提交
17 18 19 20 21 22
setTime(time : number, callback : AsyncCallback<void>) : void

Sets the system time. This API uses an asynchronous callback to return the result.

**Required permissions**: ohos.permission.SET_TIME

E
ester.zhou 已提交
23
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
24

E
ester.zhou 已提交
25
**Parameters**
W
wusongqing 已提交
26

E
ester.zhou 已提交
27 28 29
| Name  | Type           | Mandatory| Description                                      |
| -------- | ----------- | ---- | ---------------- |
| time     | number                    | Yes  | Timestamp to set, in milliseconds.                        |
E
ester.zhou 已提交
30
| callback | AsyncCallback<void> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
31 32 33

**Example**

E
ester.zhou 已提交
34 35 36 37 38 39 40 41 42 43 44
```js
// Set the system time to 2021-01-20 02:36:25.
let time = 1611081385000;
systemTime.setTime(time, (error, data) => {
    if (error) {
        console.error(`Failed to set systemTime. Cause:` + JSON.stringify(error));
        return;
    }
    console.log(`Succeeded in setting systemTime. Data:` + JSON.stringify(data));
});
```
W
wusongqing 已提交
45 46 47 48 49 50 51 52 53

## systemTime.setTime

setTime(time : number) : Promise<void>

Sets the system time. This API uses a promise to return the result.

**Required permissions**: ohos.permission.SET_TIME

E
ester.zhou 已提交
54
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
55

E
ester.zhou 已提交
56
**Parameters**
W
wusongqing 已提交
57

E
ester.zhou 已提交
58 59
| Name| Type  | Mandatory| Description              |
| ------ | ------ | ---- | ------------------ |
E
ester.zhou 已提交
60
| time   | number | Yes  | Timestamp to set, in milliseconds.|
W
wusongqing 已提交
61

E
ester.zhou 已提交
62 63
**Return value**

E
ester.zhou 已提交
64 65 66
| Type               | Description                     |
| ------------------- | ------------------------- |
| Promise<void> | Promise that returns no value.|
E
ester.zhou 已提交
67 68 69

**Example**

E
ester.zhou 已提交
70 71 72 73 74 75 76 77 78
```js
// Set the system time to 2021-01-20 02:36:25.
let time = 1611081385000;
systemTime.setTime(time).then((data) => {
    console.log(`Succeeded in setting systemTime. Data:` + JSON.stringify(data));
}).catch((error) => {
    console.error(`Failed to set systemTime. Cause:` + JSON.stringify(error));
});
```
W
wusongqing 已提交
79 80 81

## systemTime.getCurrentTime<sup>8+</sup>

E
ester.zhou 已提交
82
getCurrentTime(isNano: boolean, callback: AsyncCallback&lt;number&gt;): void
W
wusongqing 已提交
83 84 85

Obtains the time elapsed since the Unix epoch. This API uses an asynchronous callback to return the result.

E
ester.zhou 已提交
86
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
87

E
ester.zhou 已提交
88
**Parameters**
W
wusongqing 已提交
89

E
ester.zhou 已提交
90 91 92 93
| Name  | Type      | Mandatory| Description                            |
| -------- | -------------- | ---- | ------------------ |
| isNano   | boolean                     | Yes  | Whether the time to return is in nanoseconds.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the time elapsed since the Unix epoch.        |
E
ester.zhou 已提交
94 95 96

**Example**

E
ester.zhou 已提交
97 98 99 100 101 102 103 104 105
```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));
});
```
W
wusongqing 已提交
106

E
ester.zhou 已提交
107 108 109 110 111 112 113 114 115 116
## systemTime.getCurrentTime<sup>8+</sup>

getCurrentTime(callback: AsyncCallback&lt;number&gt;): void

Obtains the time elapsed since the Unix epoch. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.MiscServices.Time

**Parameters**

E
ester.zhou 已提交
117 118 119
| Name  | Type              | Mandatory| Description                           |
| -------- | ----------- | ---- | ---------------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the time elapsed since the Unix epoch.        |
E
ester.zhou 已提交
120 121 122

**Example**

E
ester.zhou 已提交
123 124 125 126 127 128 129 130 131
```js
systemTime.getCurrentTime((error, data) => {
    if (error) {
        console.error(`Succeeded in getting systemTime. Data:` + JSON.stringify(error));
        return;
    }
    console.log(`Failed to get systemTime. Cause:` + JSON.stringify(data));
});
```
E
ester.zhou 已提交
132

W
wusongqing 已提交
133 134 135 136 137 138
## systemTime.getCurrentTime<sup>8+</sup>

getCurrentTime(isNano?: boolean): Promise&lt;number&gt;

Obtains the time elapsed since the Unix epoch. This API uses a promise to return the result.

E
ester.zhou 已提交
139
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
140

E
ester.zhou 已提交
141
**Parameters**
W
wusongqing 已提交
142

E
ester.zhou 已提交
143 144 145
| Name| Type   | Mandatory| Description                    |
| ------ | ------- | ---- | ------------------------- |
| isNano | boolean | No  | Whether the time to return is in nanoseconds.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
W
wusongqing 已提交
146

E
ester.zhou 已提交
147 148
**Return value**

E
ester.zhou 已提交
149 150 151
| Type       | Description                              |
| --------------------- | --------------------------- |
| Promise&lt;number&gt; | Promise used to return the time elapsed since the Unix epoch.|
E
ester.zhou 已提交
152 153 154

**Example**

E
ester.zhou 已提交
155 156 157 158 159 160 161
```js
systemTime.getCurrentTime().then((data) => {
    console.log(`Succeeded in getting systemTime. Data:` + JSON.stringify(data));
}).catch((error) => {
    console.error(`Failed to get systemTime. Cause:` + JSON.stringify(error));
});
```
W
wusongqing 已提交
162 163 164

## systemTime.getRealActiveTime<sup>8+</sup>

E
ester.zhou 已提交
165
getRealActiveTime(isNano: boolean, callback: AsyncCallback&lt;number&gt;): void
W
wusongqing 已提交
166

E
ester.zhou 已提交
167
Obtains the time elapsed since system startup, excluding the deep sleep time. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
168

E
ester.zhou 已提交
169
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
170

E
ester.zhou 已提交
171
**Parameters**
W
wusongqing 已提交
172

E
ester.zhou 已提交
173 174 175
| Name  | Type                       | Mandatory| Description  |
| -------- | ---------- | ---- | -------------------------- |
| isNano   | boolean                     | Yes  | Whether the time to return is in nanoseconds.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
E
ester.zhou 已提交
176
| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the time.|
E
ester.zhou 已提交
177 178 179

**Example**

E
ester.zhou 已提交
180 181 182 183 184 185 186 187 188
```js
systemTime.getRealActiveTime(true, (error, data) => {
    if (error) {
        console.error(`Failed to get real active time. Cause:` + JSON.stringify(error));
        return;
    }
    console.log(`Succeeded in getting real active time. Data:` + JSON.stringify(data));
});
```
W
wusongqing 已提交
189

E
ester.zhou 已提交
190 191 192 193
## systemTime.getRealActiveTime<sup>8+</sup>

getRealActiveTime(callback: AsyncCallback&lt;number&gt;): void

E
ester.zhou 已提交
194
Obtains the time elapsed since system startup, excluding the deep sleep time. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
195 196 197 198 199

**System capability**: SystemCapability.MiscServices.Time

**Parameters**

E
ester.zhou 已提交
200 201
| Name  | Type                       | Mandatory| Description   |
| -------- | -------------- | ---- | --------------------- |
E
ester.zhou 已提交
202 203 204 205
| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the time.|

**Example**

E
ester.zhou 已提交
206 207 208 209 210 211 212 213 214
```js
systemTime.getRealActiveTime((error, data) => {
    if (error) {
        console.error(`Failed to get real active time. Cause:` + JSON.stringify(error));
        return;
    }
    console.log(`Succeeded in getting real active time. Data:` + JSON.stringify(data));
});
```
E
ester.zhou 已提交
215

W
wusongqing 已提交
216 217 218 219
## systemTime.getRealActiveTime<sup>8+</sup>

getRealActiveTime(isNano?: boolean): Promise&lt;number&gt;

E
ester.zhou 已提交
220
Obtains the time elapsed since system startup, excluding the deep sleep time. This API uses a promise to return the result.
W
wusongqing 已提交
221

E
ester.zhou 已提交
222
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
223

E
ester.zhou 已提交
224
**Parameters**
W
wusongqing 已提交
225

E
ester.zhou 已提交
226 227 228
| Name| Type   | Mandatory| Description                             |
| ------ | ------- | ---- | ----------------------------------- |
| isNano | boolean | No  | Whether the time to return is in nanoseconds.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
W
wusongqing 已提交
229

E
ester.zhou 已提交
230 231
**Return value**

E
ester.zhou 已提交
232 233 234
| Type                 | Description        |
| -------------- | -------------------------------- |
| Promise&lt;number&gt; | Promise used to return the time elapsed since system startup, excluding the deep sleep time.|
E
ester.zhou 已提交
235 236 237

**Example**

E
ester.zhou 已提交
238 239 240 241 242 243 244
```js
systemTime.getRealActiveTime().then((data) => {
    console.log(`Succeeded in getting real active time. Data:` + JSON.stringify(data));
}).catch((error) => {
    console.error(`Failed to get real active time. Cause:` + JSON.stringify(error));
});
```
W
wusongqing 已提交
245 246 247

## systemTime.getRealTime<sup>8+</sup>

E
ester.zhou 已提交
248
getRealTime(isNano: boolean, callback: AsyncCallback&lt;number&gt;): void
W
wusongqing 已提交
249

E
ester.zhou 已提交
250
Obtains the time elapsed since system startup, including the deep sleep time. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
251

E
ester.zhou 已提交
252
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
253

E
ester.zhou 已提交
254
**Parameters**
W
wusongqing 已提交
255

E
ester.zhou 已提交
256 257 258
| Name  | Type                       | Mandatory| Description  |
| -------- | --------------- | ---- | ------------------------------- |
| isNano   | boolean                     | Yes  | Whether the time to return is in nanoseconds.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
E
ester.zhou 已提交
259
| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the time.  |
E
ester.zhou 已提交
260 261 262

**Example**

E
ester.zhou 已提交
263 264 265 266 267 268 269 270 271
```js
systemTime.getRealTime(true, (error, data) => {
    if (error) {
        console.error(`Failed to get real time. Cause:` + JSON.stringify(error));
        return;
    }
    console.log(`Succeeded in getting real time. Data:` + JSON.stringify(data));
});
```
W
wusongqing 已提交
272 273 274

## systemTime.getRealTime<sup>8+</sup>

E
ester.zhou 已提交
275 276
getRealTime(callback: AsyncCallback&lt;number&gt;): void

E
ester.zhou 已提交
277
Obtains the time elapsed since system startup, including the deep sleep time. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
278 279 280 281 282

**System capability**: SystemCapability.MiscServices.Time

**Parameters**

E
ester.zhou 已提交
283 284
| Name  | Type                       | Mandatory| Description     |
| -------- | --------- | ---- | --------------------------- |
E
ester.zhou 已提交
285 286 287 288
| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the time.  |

**Example**

E
ester.zhou 已提交
289 290 291 292 293 294 295 296 297
```js
systemTime.getRealTime((error, data) => {
    if (error) {
        console.error(`Failed to get real time. Cause:` + JSON.stringify(error));
        return;
    }
    console.log(`Succeeded in getting real time. Data:` + JSON.stringify(data));
});
```
E
ester.zhou 已提交
298 299 300

## systemTime.getRealTime<sup>8+</sup>

E
ester.zhou 已提交
301
getRealTime(isNano?: boolean): Promise&lt;number&gt;
W
wusongqing 已提交
302

E
ester.zhou 已提交
303
Obtains the time elapsed since system startup, including the deep sleep time. This API uses a promise to return the result.
W
wusongqing 已提交
304

E
ester.zhou 已提交
305
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
306

E
ester.zhou 已提交
307
**Parameters**
W
wusongqing 已提交
308

E
ester.zhou 已提交
309 310 311
| Name| Type   | Mandatory| Description                              |
| ------ | ------- | ---- | ------------------------------- |
| isNano | boolean | No  | Whether the time to return is in nanoseconds.<<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
W
wusongqing 已提交
312

E
ester.zhou 已提交
313 314
**Return value**

E
ester.zhou 已提交
315 316 317
| Type                 | Description      |
| --------------------- | ------------------------------- |
| Promise&lt;number&gt; | Promise used to return the time elapsed since system startup, including the deep sleep time.|
E
ester.zhou 已提交
318 319 320

**Example**

E
ester.zhou 已提交
321 322 323 324 325 326 327
```js
systemTime.getRealTime().then((data) => {
    console.log(`Succeeded in getting real time. Data:` + JSON.stringify(data));
}).catch((error) => {
    console.error(`Failed to get real time. Cause:` + JSON.stringify(error));
});
```
W
wusongqing 已提交
328 329 330 331 332 333 334 335 336

## systemTime.setDate

setDate(date: Date, callback: AsyncCallback&lt;void&gt;): void

Sets the system date. This API uses an asynchronous callback to return the result.

**Required permissions**: ohos.permission.SET_TIME

E
ester.zhou 已提交
337
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
338

E
ester.zhou 已提交
339
**Parameters**
W
wusongqing 已提交
340

E
ester.zhou 已提交
341 342
| Name  | Type                     | Mandatory| Description            |
| -------- | ------------- | ---- | --------------------- |
E
ester.zhou 已提交
343 344
| date     | Date                      | Yes  | Target date to set.                                |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
345 346 347

**Example**

E
ester.zhou 已提交
348 349 350 351 352 353 354 355 356 357
```js
let data = new Date();
systemTime.setDate(data,(error, data) => {       
    if (error) {            
    console.error('Failed to set system date. Cause:' + JSON.stringify(error));           
    return;       
}        
    console.info('Succeeded in setting system date. Data:' + JSON.stringify(data));    
});
```
W
wusongqing 已提交
358 359 360 361 362 363 364 365 366

## systemTime.setDate

setDate(date: Date): Promise&lt;void&gt;

Sets the system date. This API uses a promise to return the result.

**Required permissions**: ohos.permission.SET_TIME

E
ester.zhou 已提交
367
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
368

E
ester.zhou 已提交
369
**Parameters**
W
wusongqing 已提交
370

E
ester.zhou 已提交
371 372 373
| Name| Type| Mandatory| Description      |
| ------ | ---- | ---- | ---------- |
| date   | Date | Yes  | Target date to set.|
W
wusongqing 已提交
374

E
ester.zhou 已提交
375 376
**Return value**

E
ester.zhou 已提交
377 378
| Type               | Description                |
| ------------------- | -------------------- |
E
ester.zhou 已提交
379
| Promise&lt;void&gt; | Promise that returns no value.|
E
ester.zhou 已提交
380 381 382

**Example**

E
ester.zhou 已提交
383 384 385 386 387 388 389 390
```js
let data = new Date(); 
systemTime.setDate(data).then((value) => {        
    console.log(`Succeeded in setting system date. Data:` + JSON.stringify(value));    
}).catch((error) => {        
    console.error(`Failed to set system date. Cause:` + JSON.stringify(error));
});
```
W
wusongqing 已提交
391 392 393 394 395 396 397

## systemTime.getDate<sup>8+</sup>

getDate(callback: AsyncCallback&lt;Date&gt;): void

Obtains the current system date. This API uses an asynchronous callback to return the result.

E
ester.zhou 已提交
398
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
399

E
ester.zhou 已提交
400
**Parameters**
W
wusongqing 已提交
401

E
ester.zhou 已提交
402 403
| Name  | Type          | Mandatory| Description                  |
| -------- | -------------- | ---- | --------------------- |
E
ester.zhou 已提交
404
| callback | AsyncCallback&lt;Date&gt; | Yes  | Callback used to return the current system date.|
E
ester.zhou 已提交
405 406 407

**Example**

E
ester.zhou 已提交
408 409 410 411 412 413 414 415 416
```js
systemTime.getDate((error, data) => {
    if (error) {
        console.error(`Failed to get system date. Cause:` + JSON.stringify(error));
        return;
    }
    console.log(`Succeeded in getting system date. Data:` + JSON.stringify(data));
});
```
W
wusongqing 已提交
417 418 419 420 421

## systemTime.getDate<sup>8+</sup>

getDate(): Promise&lt;Date&gt;

E
ester.zhou 已提交
422
Obtains the current system date. This API uses a promise to return the result.  
W
wusongqing 已提交
423

E
ester.zhou 已提交
424
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
425

E
ester.zhou 已提交
426
**Return value**
W
wusongqing 已提交
427

E
ester.zhou 已提交
428 429
| Type               | Description                                     |
| ------------------- | ----------------------------------------- |
E
ester.zhou 已提交
430 431 432 433
| Promise&lt;Date&gt; | Promise used to return the current system date.|

**Example**

E
ester.zhou 已提交
434 435 436 437 438 439 440
```js
systemTime.getDate().then((data) => {
    console.log(`Succeeded in getting system date. Data:` + JSON.stringify(data));
}).catch((error) => {
    console.error(`Failed to get system date. Cause:` + JSON.stringify(error));
});
```
W
wusongqing 已提交
441 442 443 444 445 446 447 448 449

## systemTime.setTimezone

setTimezone(timezone: string, callback: AsyncCallback&lt;void&gt;): void

Sets the system time zone. This API uses an asynchronous callback to return the result.

**Required permissions**: ohos.permission.SET_TIME_ZONE

E
ester.zhou 已提交
450
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
451

E
ester.zhou 已提交
452
**Parameters**
W
wusongqing 已提交
453

E
ester.zhou 已提交
454 455
| Name  | Type             | Mandatory| Description                 |
| -------- | ------------- | ---- | -------------------------- |
E
ester.zhou 已提交
456 457
| timezone | string                    | Yes  | System time zone to set.                                |
| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
458 459 460

**Example**

E
ester.zhou 已提交
461 462 463 464 465 466 467 468 469
```js
systemTime.setTimezone('Asia/Shanghai', (error, data) => {       
    if (error) {          
        console.error('Failed to set system time zone. Cause:' + JSON.stringify(error));         
        return;       
    }       
    console.info('Succeeded in setting system time zone. Data:' + JSON.stringify(data)); 
});
```
W
wusongqing 已提交
470 471 472 473 474 475 476 477 478

## systemTime.setTimezone

setTimezone(timezone: string): Promise&lt;void&gt;

Sets the system time zone. This API uses a promise to return the result.

**Required permissions**: ohos.permission.SET_TIME_ZONE

E
ester.zhou 已提交
479
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
480

E
ester.zhou 已提交
481
**Parameters**
W
wusongqing 已提交
482

E
ester.zhou 已提交
483 484 485
| Name  | Type  | Mandatory| Description      |
| -------- | ------ | ---- | ---------- |
| timezone | string | Yes  | System time zone to set.|
W
wusongqing 已提交
486

E
ester.zhou 已提交
487 488
**Return value**

E
ester.zhou 已提交
489 490
| Type               | Description                |
| ------------------- | -------------------- |
E
ester.zhou 已提交
491
| Promise&lt;void&gt; | Promise that returns no value.|
E
ester.zhou 已提交
492 493 494

**Example**

E
ester.zhou 已提交
495 496 497 498 499 500 501
```js
systemTime.setTimezone('Asia/Shanghai').then((data) => {        
    console.log(`Succeeded in setting system time zone. Data:` + JSON.stringify(data));     
}).catch((error) => {        
    console.error(`Failed to set system time zone. Cause:` + JSON.stringify(error));    
});
```
W
wusongqing 已提交
502 503 504 505 506 507 508

## systemTime.getTimezone<sup>8+</sup>

getTimezone(callback: AsyncCallback&lt;string&gt;): void

Obtains the system time zone. This API uses an asynchronous callback to return the result.

E
ester.zhou 已提交
509
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
510

E
ester.zhou 已提交
511
**Parameters**
W
wusongqing 已提交
512

E
ester.zhou 已提交
513 514
| Name  | Type             | Mandatory| Description                |
| -------- | --------- | ---- | ------------------------ |
E
ester.zhou 已提交
515
| callback | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the system time zone.|
E
ester.zhou 已提交
516 517 518

**Example**

E
ester.zhou 已提交
519 520 521 522 523 524 525 526 527
```js
systemTime.getTimezone((error, data) => {
    if (error) {
        console.error(`Failed to get system time zone. Cause:` + JSON.stringify(error));
        return;
    }
    console.log(`Succeeded in getting system time zone. Data:` + JSON.stringify(data));
});
```
W
wusongqing 已提交
528 529 530 531 532 533 534

## systemTime.getTimezone<sup>8+</sup>

getTimezone(): Promise&lt;string&gt;

Obtains the system time zone. This API uses a promise to return the result.

E
ester.zhou 已提交
535
**System capability**: SystemCapability.MiscServices.Time
W
wusongqing 已提交
536

E
ester.zhou 已提交
537
**Return value**
W
wusongqing 已提交
538

E
ester.zhou 已提交
539 540
| Type                 | Description                                 |
| --------------------- | ------------------------------------- |
E
ester.zhou 已提交
541 542 543 544
| Promise&lt;string&gt; | Promise used to return the system time zone.|

**Example**

E
ester.zhou 已提交
545 546 547 548 549 550 551
```js
systemTime.getTimezone().then((data) => {
    console.log(`Succeeded in getting system time zone. Data:` + JSON.stringify(data));
}).catch((error) => {
    console.error(`Failed to get system time zone. Cause:` + JSON.stringify(error));
});
```