Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 453
  • Last Modified:

CTime::Format() and regional settings

Is there a way to access the Windows time/date regional settings when you are creating a format string?  For instance, my date format might be "4 Aug 98" but someone in the States might use "8/4/1998."  and it seems the same code ought to figure this out and adjust its results.
  • 3
1 Solution
Sure.  There's a whole system of 'locales' to deal with this.  Try:

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

int GetDateFormat( LCID Locale,
 // locale for which date is to be formatted
DWORD dwFlags,
 // flags specifying function options
 // date to be formatted
LPCTSTR lpFormat,
 // date format string
LPTSTR lpDateStr,
 // buffer for storing formatted string
int cchDate
 // size of buffer


There's a real good discussion in the 'Going Global' site from Microsoft.

And another with an example on how to display today's date in the current locale.  There's also a small sample code at the site as well.

Also, don't forget to look for the Microsoft Press® book Developing International Software.  I found it very helpful but was disappointed to see the far-east character tables used as filler.

Good Luck


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now