|
-
May 28th, 1999, 06:40 AM
#1
Formatting date
I want to display date in local system format.
For example : dd/mm/yyyy for france and mm/dd/yyyy for us.
I try the following code but it didn't work :
CTime time = CTime::GetCurrentTime();
CString strDate = time.Format(_T("%x"));
In fact this code ALWAYS results in : mm/dd/yyyy
Please help
-
May 28th, 1999, 07:15 AM
#2
Re: Formatting date
Have you changed your locale settings in Regional Settings ?
-
May 28th, 1999, 08:17 AM
#3
Re: Formatting date
Yes I have.
Therefore a customer test with england local settings and the problem is identical.
Note : The systems used are NT or w98.
-
May 28th, 1999, 08:24 AM
#4
Re: Formatting date
Can you not do
date.format(%d/%m/%y);
-
May 28th, 1999, 08:51 AM
#5
Re: Formatting date
I've tested here at my portable. And I have the same problem.
-
May 28th, 1999, 09:48 AM
#6
Re: Formatting date
Try this.
COleDateTime timeNow;
timeNow = COleDateTime::GetCurrentTime();
CString strDate = timeNow.Format(VAR_DATEVALUEONLY);
CString strTime = timeNow.Format(VAR_TIMEVALUEONLY);
-
May 28th, 1999, 11:21 AM
#7
Re: Formatting date
Hi,
I think you may have to get around this problem by reading the settings from the registry used by the current user.
If you look at the key
[HKEY_CURRENT_USER\Control Panel\International]
The sub-key "sShortDate"="M/d/yyyy" tells you what format you would be required to display your date in. You would only have to parse this to get the information you need.
HTH
Roger Allen
Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
Please remember to rate useful answers. It lets us know when a question has been answered.
-
June 22nd, 1999, 02:54 AM
#8
Re: Formatting date
First of all: Skip CTime! COleDateTime will last for quite a while longer.
Then, formatting as regional settings can be done like this:
COleDateTime dt;
CString szDate;
szDate = dt.Format(VAR_DATEVALUEONLY , LANG_USER_DEFAULT);
// and the other way around
dt.ParseDateTime( szDate, VAR_DATEVALUEONLY, LANG_USER_DEFAULT );
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|