WinHttpTimeToSystemTime function (winhttp.h)

The WinHttpTimeToSystemTime function takes an HTTP time/date string and converts it to a SYSTEMTIME structure.

Syntax

WINHTTPAPI BOOL WinHttpTimeToSystemTime(
  [in]  LPCWSTR    pwszTime,
  [out] SYSTEMTIME *pst
);

Parameters

[in] pwszTime

Pointer to a null-terminated date/time string to convert. This value must use the format defined in section 3.3 of the RFC2616.

[out] pst

Pointer to the SYSTEMTIME structure that receives the converted time.

Return value

Returns TRUE if successful, or FALSE otherwise. For extended error information, call GetLastError. Among the error codes returned is:

Error Code Description
ERROR_WINHTTP_INTERNAL_ERROR
An internal error has occurred.

Remarks

Even when WinHTTP is used in asynchronous mode (that is, when WINHTTP_FLAG_ASYNC has been set in WinHttpOpen), this function operates synchronously. The return value indicates success or failure. To get extended error information, call GetLastError.

Note  For Windows XP and Windows 2000, see the Run-Time Requirements section of the WinHttp start page.
 

Examples

This example shows how to convert an HTTP formatted date to a SYSTEMTIME structure.

    SYSTEMTIME  sTime;
    LPCWSTR     pwszTimeStr = L"Tue, 21 Nov 2000 01:06:53 GMT";

    // Convert the HTTP string to a SYSTEMTIME structure.
    if (!WinHttpTimeToSystemTime( pwszTimeStr, &sTime))
    {
        printf( "Error %u in WinHttpTimeToSystemTime.\n", GetLastError());
    }
    else
    {
        // Print the date.
        printf( "The U.S. formatted date is (%u/%u/%u)\n", 
                sTime.wMonth, sTime.wDay, sTime.wYear);
    }

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional with SP3 [desktop apps only]
Minimum supported server Windows Server 2003, Windows 2000 Server with SP3 [desktop apps only]
Target Platform Windows
Header winhttp.h
Library Winhttp.lib
DLL Winhttp.dll
Redistributable WinHTTP 5.0 and Internet Explorer 5.01 or later on Windows XP and Windows 2000.

See also

About Microsoft Windows HTTP Services (WinHTTP)

WinHTTP Versions

WinHttpTimeFromSystemTime