Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

EnumTimeFormats function

Enumerates the time formats that are available for a locale specified by identifier.

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


BOOL EnumTimeFormats(
  _In_ TIMEFMT_ENUMPROC lpTimeFmtEnumProc,
  _In_ LCID             Locale,
  _In_ DWORD            dwFlags


lpTimeFmtEnumProc [in]

Pointer to an application-defined callback function. For more information, see EnumTimeFormatsProc.

Locale [in]

Locale identifier that specifies the locale for which to retrieve time format information. You can use the MAKELCID macro to create a locale identifier or use one of the following predefined values.

dwFlags [in]

The time format. This parameter can specify a combination of any of the following values.


Use the current user's long time format.


Windows 7 and later: Use the current user's short time format.

Note  This value will not work with the ANSI version of this function, EnumTimeFormatsA.

Specified with the ANSI version of this function, EnumTimeFormatsA (not recommended), to use the system default Windows ANSI code page (ACP) instead of the locale code page.


Return value

Returns a nonzero value if successful, or 0 otherwise. To get extended error information, the application can call GetLastError, which can return one of the following error codes:

  • ERROR_INVALID_FLAGS. The values supplied for flags were not valid.
  • ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.


The function enumerates the time formats by passing a pointer to a buffer containing a time format to an application-defined callback function. The first value in the enumeration is always the user default (override) value. The function continues enumeration until the last time format is found or the callback function returns FALSE.

This function can enumerate data from custom locales. Data is not guaranteed to be the same from computer to computer or between runs of an application. If your application must persist or transmit data, see Using Persistent Locale Data.

When the ANSI version of this function is used with a Unicode-only locale identifier, the call can succeed because the system uses the system code page. However, characters that are undefined in the system code page appear in the string as a question mark ("?"). Note that any new values for dwFlags introduced in the future will not work with the ANSI version.


Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]


Winnls.h (include Windows.h)





Unicode and ANSI names

EnumTimeFormatsW (Unicode) and EnumTimeFormatsA (ANSI)

See also

National Language Support
National Language Support Functions



© 2018 Microsoft