You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Converts a **time_t** time value to a **tm** structure. More secure versions of these functions are available; see [gmtime_s, _gmtime32_s, _gmtime64_s](gmtime-s-gmtime32-s-gmtime64-s.md).
15
+
Converts a `time_t` time value to a `tm` structure. More secure versions of these functions are available; see [`gmtime_s`, `_gmtime32_s`, `_gmtime64_s`](gmtime-s-gmtime32-s-gmtime64-s.md).
Pointer to the stored time. The time is represented as seconds elapsed since midnight (00:00:00), January 1, 1970, coordinated universal time (UTC).
29
29
30
30
## Return Value
31
31
32
-
A pointer to a structure of type [tm](../../c-runtime-library/standard-types.md). The fields of the returned structure hold the evaluated value of the *sourceTime* argument in UTC rather than in local time. Each of the structure fields is of type **`int`**, as follows:
32
+
A pointer to a structure of type [`tm`](../../c-runtime-library/standard-types.md). The fields of the returned structure hold the evaluated value of the *`sourceTime`* argument in UTC rather than in local time. Each of the structure fields is of type `int`, as follows:
33
33
34
34
|Field|Description|
35
35
|-|-|
36
-
|**tm_sec**|Seconds after minute (0 - 59).|
37
-
|**tm_min**|Minutes after hour (0 - 59).|
38
-
|**tm_hour**|Hours since midnight (0 - 23).|
39
-
|**tm_mday**|Day of month (1 - 31).|
40
-
|**tm_mon**|Month (0 - 11; January = 0).|
41
-
|**tm_year**|Year (current year minus 1900).|
42
-
|**tm_wday**|Day of week (0 - 6; Sunday = 0).|
43
-
|**tm_yday**|Day of year (0 - 365; January 1 = 0).|
44
-
|**tm_isdst**|Always 0 for **gmtime**.|
36
+
|`tm_sec`|Seconds after minute (0 - 59).|
37
+
|`tm_min`|Minutes after hour (0 - 59).|
38
+
|`tm_hour`|Hours since midnight (0 - 23).|
39
+
|`tm_mday`|Day of month (1 - 31).|
40
+
|`tm_mon`|Month (0 - 11; January = 0).|
41
+
|`tm_year`|Year (current year minus 1900).|
42
+
|`tm_wday`|Day of week (0 - 6; Sunday = 0).|
43
+
|`tm_yday`|Day of year (0 - 365; January 1 = 0).|
44
+
|`tm_isdst`|Always 0 for **gmtime**.|
45
45
46
-
Both the 32-bit and 64-bit versions of **gmtime**, [mktime](mktime-mktime32-mktime64.md), [mkgmtime](mkgmtime-mkgmtime32-mkgmtime64.md), and [localtime](localtime-localtime32-localtime64.md) all use one common **tm** structure per thread for the conversion. Each call to one of these functions destroys the result of any previous call. If *sourceTime* represents a date before midnight, January 1, 1970, **gmtime** returns **NULL**. There's no error return.
46
+
Both the 32-bit and 64-bit versions of **`gmtime`**, [`mktime`](mktime-mktime32-mktime64.md), [`mkgmtime`](mkgmtime-mkgmtime32-mkgmtime64.md), and [`localtime`](localtime-localtime32-localtime64.md) all use one common `tm` structure per thread for the conversion. Each call to one of these functions destroys the result of any previous call. If *`sourceTime`* represents a date before midnight, January 1, 1970, **`gmtime`** returns `NULL`. There's no error return.
47
47
48
-
**_gmtime64**, which uses the **__time64_t** structure, enables dates to be expressed up through 23:59:59, December 31, 3000, UTC, whereas **_gmtime32** only represent dates through 23:59:59 January 18, 2038, UTC. Midnight, January 1, 1970, is the lower bound of the date range for both functions.
48
+
**_gmtime64**, which uses the `__time64_t` structure, enables dates to be expressed up through 23:59:59, December 31, 3000, UTC, whereas **`_gmtime32`** only represent dates through 23:59:59 January 18, 2038, UTC. Midnight, January 1, 1970, is the lower bound of the date range for both functions.
49
49
50
-
**gmtime** is an inline function that evaluates to **_gmtime64**, and **time_t** is equivalent to **__time64_t** unless **_USE_32BIT_TIME_T** is defined. If you must force the compiler to interpret **time_t** as the old 32-bit **time_t**, you can define **_USE_32BIT_TIME_T**, but doing so causes **gmtime** to be in-lined to **_gmtime32** and **time_t** to be defined as **__time32_t**. We recommend that you do not do this, because it is not allowed on 64-bit platforms and in any case your application may fail after January 18, 2038.
50
+
**`gmtime`** is an inline function that evaluates to **`_gmtime64`**, and `time_t` is equivalent to `__time64_t` unless `_USE_32BIT_TIME_T` is defined. If you must force the compiler to interpret `time_t` as the old 32-bit `time_t`, you can define `_USE_32BIT_TIME_T`, but doing so causes **`gmtime`** to be in-lined to **`_gmtime32`** and `time_t` to be defined as `__time32_t`. We don't recommend that you do this, because it isn't allowed on 64-bit platforms. In any case, your application may fail after January 18, 2038.
51
51
52
-
These functions validate their parameters. If *sourceTime* is a null pointer, or if the *sourceTime* value is negative, these functions invoke an invalid parameter handler, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, the functions return **NULL** and set **errno** to **EINVAL**.
52
+
These functions validate their parameters. If *`sourceTime`* is a null pointer, or if the *`sourceTime`* value is negative, these functions invoke an invalid parameter handler, as described in [Parameter validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, the functions return `NULL` and set `errno` to `EINVAL`.
53
53
54
54
## Remarks
55
55
56
-
The **_gmtime32** function breaks down the *sourceTime* value and stores it in a statically allocated structure of type **tm**, defined in TIME.H. The value of *sourceTime* is typically obtained from a call to the [time](time-time32-time64.md) function.
56
+
The **`_gmtime32`** function breaks down the *`sourceTime`* value and stores it in a statically allocated structure of type `tm`, defined in `TIME.H`. The value of *`sourceTime`* is typically obtained from a call to the [`time`](time-time32-time64.md) function.
57
57
58
58
> [!NOTE]
59
59
> In most cases, the target environment tries to determine whether daylight savings time is in effect. The C run-time library assumes that the United States rules for implementing the calculation of Daylight Saving Time (DST) are used.
@@ -64,7 +64,7 @@ By default, this function's global state is scoped to the application. To change
64
64
65
65
|Routine|Required C header|Required C++ header|
66
66
|-------------|---------------------|-|
67
-
|**gmtime**, **_gmtime32**, **_gmtime64**|\<time.h>|\<ctime> or \<time.h>|
67
+
|**`gmtime`**, **`_gmtime32`**, **`_gmtime64`**|`<time.h>`| `<ctime>` or `<time.h>`|
68
68
69
69
For additional compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
70
70
@@ -81,7 +81,7 @@ For additional compatibility information, see [Compatibility](../../c-runtime-li
81
81
#include <time.h>
82
82
#include <stdio.h>
83
83
84
-
int main(void)
84
+
int main(void)
85
85
{
86
86
struct tm *newtime;
87
87
__int64 ltime;
@@ -103,12 +103,12 @@ Coordinated universal time is Tue Feb 12 23:11:31 2002
0 commit comments