Advertisement

How to get time & date? (in VC6)

Started by December 16, 2000 01:08 PM
6 comments, last by civguy 24 years, 1 month ago
How to get time and date from your computer in VC++ 6.0? I don''t want to use timeGetTime() because it doesn''t return the time like: "5:30:21am 15th Nov 2000" Tnx in advance!
I doubt anything returns the time in that sort of format, you are gonna have to produce the formatting yourself.
(Although I think MFC CTime can do this)
Advertisement
I wanted to do some time work, so I loked around....
the c++ standard time funcs are slow(1 sec intervals) and i dont care for them. I havnt used the w32 funcs...they are probably slow. I reccomend asm.
Be careful tho...you might end up with some odd times on the computer; I did. :-)
interrupt 1a is the time call, I`ve never had occasion to want the date one. Somewhere there should be a list of the interrupts and the registers they use...
You have to format it yourself, of course...
Actually, once you find the functions/interrupts you need, it should be pretty easy.
You just whip up a cDT class and work from there...
DTs:-p
Anyway, good luck.
~V''lion



I came, I saw, I got programmers block.
~V''''lion
~V'lionBugle4d
If you only care about Windows then GetTimeFormat and GetDateFormat will format times and dates in just about any way you want.

-Mike
Tnx Vlion, but I don''t like writing asm..it looks ugly .

But Mike, those functions did the trick, tnx!
Have you looked into "time_t"???
Look for this function in MSDN and you should find everything you need..

...
time_t time( time_t *timer );
...

Hope this helps...

ZaneX
Advertisement
time.h contains about all the time functions you need, including millisecs etc.
  time_t clock;char localTime[32];time(&clock);strcpy(localTime, asctime(localtime(&clock)));  


All the functions, time(), localtime(), and asctime() are standard C library functions. Really, people, you need to read your documentation before posting questions like this.

This topic is closed to new replies.

Advertisement