Skip to content

Latest commit

 

History

History
137 lines (97 loc) · 3.69 KB

File metadata and controls

137 lines (97 loc) · 3.69 KB
UID NF:sysinfoapi.GetSystemTime
title GetSystemTime function (sysinfoapi.h)
description Retrieves the current system date and time in Coordinated Universal Time (UTC) format.
helpviewer_keywords
GetSystemTime
GetSystemTime function
_win32_getsystemtime
base.getsystemtime
sysinfoapi/GetSystemTime
old-location base\getsystemtime.htm
tech.root winprog
ms.assetid 9ed8386b-f035-446f-b0f8-12e0d3f23aac
ms.date 12/05/2018
ms.keywords GetSystemTime, GetSystemTime function, _win32_getsystemtime, base.getsystemtime, sysinfoapi/GetSystemTime
req.header sysinfoapi.h
req.include-header Windows.h
req.target-type Windows
req.target-min-winverclnt Windows 2000 Professional [desktop apps \| UWP apps]
req.target-min-winversvr Windows 2000 Server [desktop apps \| UWP apps]
req.kmdf-ver
req.umdf-ver
req.ddi-compliance
req.unicode-ansi
req.idl
req.max-support
req.namespace
req.assembly
req.type-library
req.lib Kernel32.lib
req.dll Kernel32.dll
req.irql
targetos Windows
req.typenames
req.redist
ms.custom snippet-project
f1_keywords
GetSystemTime
sysinfoapi/GetSystemTime
dev_langs
c++
topic_type
APIRef
kbSyntax
api_type
DllExport
api_location
api-ms-win-core-sysinfo-l1-2-7.dll
api-ms-win-core-sysinfo-l1-2-6.dll
api-ms-win-core-sysinfo-l1-2-5.dll
api-ms-win-core-sysinfo-l1-2-4.dll
Kernel32.dll
API-MS-Win-Core-SysInfo-l1-1-0.dll
KernelBase.dll
API-MS-Win-Core-SysInfo-l1-2-0.dll
API-MS-Win-Core-SysInfo-l1-2-1.dll
API-MS-Win-Core-SysInfo-l1-2-2.dll
API-MS-Win-DownLevel-Kernel32-l1-1-0.dll
MinKernelBase.dll
API-MS-Win-Core-SysInfo-l1-2-3.dll
api_name
GetSystemTime

GetSystemTime function

-description

Retrieves the current system date and time in Coordinated Universal Time (UTC) format.

To retrieve the current system date and time in local time, use the GetLocalTime function.

-parameters

-param lpSystemTime [out]

A pointer to a SYSTEMTIME structure to receive the current system date and time. The lpSystemTime parameter must not be NULL. Using NULL will result in an access violation.

-remarks

To set the current system date and time, use the SetSystemTime function.

Examples

#include <windows.h>
#include <stdio.h>

void main()
{
    SYSTEMTIME st, lt;
    
    GetSystemTime(&st);
    GetLocalTime(&lt);
    
    printf("The system time is: %02d:%02d\n", st.wHour, st.wMinute);
    printf(" The local time is: %02d:%02d\n", lt.wHour, lt.wMinute);
}
// Sample output

The system time is: 19:34
 The local time is: 12:34

For more information about this example, see SYSTEMTIME.

-see-also

GetLocalTime

GetSystemTimeAdjustment

GetSystemTimeAsFileTime

SYSTEMTIME

SetSystemTime

System Time

Time Functions