CTime::Format()  and regional settings

Posted on 1998-08-24
Last Modified: 2013-11-19
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.
Question by:standefe
  • 3

Accepted Solution

psdavis earned 180 total points
ID: 1321237
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



Expert Comment

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


Expert Comment

ID: 1321239
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



Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now