Share via


CTime::GetGmtTm

structtm*GetGmtTm(structtm*ptm=NULL)const;

Return Value

A pointer to a filled-in struct tm as defined in the include file TIME.H. The members and the values they store are as follows:

  • tm_sec   Seconds

  • tm_min   Minutes

  • tm_hour   Hours (0–23)

  • tm_mday   Day of month (1–31)

  • tm_mon   Month (0–11; January = 0)

  • tm_year   Year (actual year minus 1900)

  • tm_wday   Day of week (1–7; Sunday = 1)

  • tm_yday   Day of year (0–365; January 1 = 0)

  • tm_isdst   Always 0

Note   The year in struct tm is in the range 70 to 138; the year in the CTime interface is in the range January 1, 1970 to January 18, 2038 (inclusive).

Parameters

ptm

Points to a buffer that will receive the time data. If this pointer is NULL, an internal, statically allocated buffer is used. The data in this default buffer is overwritten as a result of calls to other CTime member functions.

Remarks

Gets a struct tm that contains a decomposition of the time contained in this CTime object. GetGmtTm returns UTC.

This function calls GetLocalTm, which uses an internal, statically allocated buffer. The data in this buffer is overwritten as a result of calls to other CTime member functions.

Example

// Compute difference between local time and GMT
   CTime time(CTime::GetCurrentTime());
   tm t1 = *(time.GetLocalTm());
   tm t2 = *(time.GetGmtTm());

   TRACE("Difference between local time and GMT is %d hours.\n", t1.tm_hour - t2.tm_hour);

CTime OverviewClass MembersHierarchy Chart