How to format COleDateTime
I was developing the project in the visual c++ platform where I got struck with the date and time format I want to know when I’m using:
Code:
COleDateTime e(2011, 6, 11, 0,0,1);
tprintf(e.Format());
Is giving me the output of "6/11/2011 12:00:01 AM" and when I’m trying the code:
COleDateTime e(2011, 9, 11, 0,0,0);
tprintf(e.Format());
Then why it is giving the output like this "9/11/2011"? Does anyone know the reason behind it?
Re: How to format COleDateTime
I had search for it on the net. It really simple and required a little bit logic to do so. This kind is as well use toward corresponding to date-only or else time-only values. According to the rule, the date 0 like if you write (29 November 1980) is most probably used in favor of only time values. In the same way, the time 0:00 which is also known as a midnight is usually used for the only the date values. Hope this will help you.
Re: How to format COleDateTime
That kind of date time format is usually used in the specification of national language for date or time i.e. local ids. By making use of an local parameter and if your are specifying the value as 0(12 June 1990) as per the data and time format this will only going to print the date value in the same way in the default parameters it will only going to print an date value only if the time value in it is 0 which mean midnight. You can even print midnight in your result by providing the value as 0 (12 June 1990, midnight).
Re: How to format COleDateTime
Even I was searching for the same I think so it’s only on older version? In the older version it use to run in its own container but now in the new version it use to run in the web browser which make it own search with the help of API which is well-suited with the windows 9x. I don’t know why they had made the coledate time format as it’s really bad in working with the time format for the midnight and if you try in your program.
Re: How to format COleDateTime
You can try something new for the parameter which is not default.
Code:
LOCALE_NOUSEROVERRIDE make use of the system default settings.
VAR_TIMEVALUEONLY pay no attention to the date section throughout parsing.
VAR_DATEVALUEONLY pay no attention to the time section throughout parsing.
Use anyone of them. It is used for the local flags.
Re: How to format COleDateTime
Why you are not explicitly specifying which ever format you needed. For window user local format you can use this
Code:
#include <windows.h>
#include <ATLComTime.h>
int main()
{ COleDateTime q1(2011, 9, 11, 0,0,1);
_tprintf("%s\n", q1.Format(TEXT("%c")));
COleDateTime w1(2011, 9, 11, 0,0,0);
_tprintf("%s\n", w1.Format(TEXT("%c")));
return 0;
}
This will give an output as
09/11/11 00:00:01
9/11/2011