Skip to content

Latest commit

 

History

History
178 lines (119 loc) · 7.79 KB

nf-datetimeapi-getdateformatw.md

File metadata and controls

178 lines (119 loc) · 7.79 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr 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 req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:datetimeapi.GetDateFormatW
GetDateFormatW function (datetimeapi.h)
Formats a date as a date string for a locale specified by the locale identifier. (Unicode)
GetDateFormat
GetDateFormat function [Internationalization for Windows Applications]
GetDateFormatW
_win32_GetDateFormat
datetimeapi/GetDateFormat
datetimeapi/GetDateFormatW
intl.getdateformat
intl\getdateformat.htm
Intl
546cede1-1702-403a-bba3-b5cd3b35a1bf
12/05/2018
GetDateFormat, GetDateFormat function [Internationalization for Windows Applications], GetDateFormatA, GetDateFormatW, _win32_GetDateFormat, datetimeapi/GetDateFormat, datetimeapi/GetDateFormatA, datetimeapi/GetDateFormatW, intl.getdateformat
datetimeapi.h
Windows
Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
GetDateFormatW (Unicode) and GetDateFormatA (ANSI)
Kernel32.lib
Kernel32.dll
Windows
19H1
GetDateFormatW
datetimeapi/GetDateFormatW
c++
APIRef
kbSyntax
DllExport
Kernel32.dll
API-MS-Win-Core-datetime-l1-1-0.dll
KernelBase.dll
API-MS-Win-Core-datetime-l1-1-1.dll
API-MS-Win-DownLevel-Kernel32-l1-1-0.dll
MinKernelBase.dll
API-MS-Win-Core-DateTime-L1-1-2.dll
GetDateFormat
GetDateFormatA
GetDateFormatW

GetDateFormatW function

-description

Formats a date as a date string for a locale specified by the locale identifier. The function formats either a specified date or the local system date.

Note  For interoperability reasons, the application should prefer the GetDateFormatEx function to GetDateFormat because Microsoft is migrating toward the use of locale names instead of locale identifiers for new locales. Any application that will be run only on Windows Vista and later should use GetDateFormatEx.

 

-parameters

-param Locale [in]

Locale identifier that specifies the locale this function formats the date string for. You can use the MAKELCID macro to create a locale identifier or use one of the following predefined values.

-param dwFlags [in]

Flags specifying date format options. For detailed definitions, see the dwFlags parameter of GetDateFormatEx.

-param lpDate [in, optional]

Pointer to a SYSTEMTIME structure that contains the date information to format. The application sets this parameter to NULL if the function is to use the current local system date.

-param lpFormat [in, optional]

Pointer to a format picture string that is used to form the date. Possible values for the format picture string are defined in Day, Month, Year, and Era Format Pictures.

The function uses the specified locale only for information not specified in the format picture string, for example, the day and month names for the locale. The application can set this parameter to NULL to format the string according to the date format for the specified locale.

-param lpDateStr [out, optional]

Pointer to a buffer in which this function retrieves the formatted date string.

-param cchDate [in]

Size, in characters, of the lpDateStr buffer. The application can set this parameter to 0 to return the buffer size required to hold the formatted date string. In this case, the buffer indicated by lpDateStr is not used.

-returns

Returns the number of characters written to the lpDateStr buffer if successful. If the cchDate parameter is set to 0, the function returns the number of characters required to hold the formatted date string, including the terminating null character.

The function returns 0 if it does not succeed. To get extended error information, the application can call GetLastError, which can return one of the following error codes:

  • ERROR_INSUFFICIENT_BUFFER. A supplied buffer size was not large enough, or it was incorrectly set to NULL.
  • ERROR_INVALID_FLAGS. The values supplied for flags were not valid.
  • ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.

-remarks

Note  This API is being updated to support the May 2019 Japanese era change. If your application supports the Japanese calendar, you should validate that it properly handles the new era. See Prepare your application for the Japanese era change for more information.
 
See Remarks for GetDateFormatEx.

When the ANSI version of this function is used with a Unicode-only locale identifier, the function can succeed because the operating system uses the system code page. However, characters that are undefined in the system code page appear in the string as a question mark ("?").

Starting with Windows 8: GetDateFormat is declared in Datetimeapi.h. Before Windows 8, it was declared in Winnls.h.

Note

The datetimeapi.h header defines GetDateFormat as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

-see-also

Day, Month, Year, and Era Format Pictures

EnumCalendarInfo

EnumDateFormatsEx

GetCalendarInfo

GetDateFormatEx

GetLocaleInfo

GetTimeFormat

National Language Support

National Language Support Functions