WinHttpTimeToSystemTime function

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

Syntax


BOOL WINAPI WinHttpTimeToSystemTime(
  _In_   LPCWSTR pwszTime,
  _Out_  SYSTEMTIME *pst
);

Parameters

pwszTime [in]

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

pst [out]

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 CodeDescription
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

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]

Redistributable

WinHTTP 5.0 and Internet Explorer 5.01 or later on Windows XP and Windows 2000.

Header

Winhttp.h

Library

Winhttp.lib

DLL

Winhttp.dll

See also

About Microsoft Windows HTTP Services (WinHTTP)
WinHttpTimeFromSystemTime
WinHTTP Versions

 

 

Community Additions

ADD
Show:
© 2015 Microsoft