C++ Date and Time questions

Associate
Joined
18 Oct 2002
Posts
710
Location
Somerset
I am putting together a program in C++ and have run into some problems with dates and times.

First off the biggest problem,
I need to take the current (each time a button is clicked) system time and assign it to a variable.
how do i get the system time? and what format will it be in?

after that i need to do some work with the value of the variable that i think i can handel.

2nd
I have a DateTimePicker in the program for the user to select another time from.
when run it will only cycle upto 23 or down to 1 it will not go to 00 in either direction,
only way i have found to sort this is to change ShowCheckbox to true,
this adds a little checkbox to the left of the time but i dont want it on view,
other programs i have seen cycle through 00 ok with this checkbox in view.

Any pointers greatly recieved.
Thanks
Dr Z
 
Associate
OP
Joined
18 Oct 2002
Posts
710
Location
Somerset
Thanks yhack i have that information avaliable to me in builders help files,

but it is still getting me no were,

what i need is to read in the current time from the system and split it out into hours mins and secs assigned to seperate variables,

i have been trying to use differant methods to do this but am not geting any were
 
Associate
Joined
30 May 2006
Posts
70
Dr Zoidberg said:
Thanks yhack i have that information avaliable to me in builders help files,

but it is still getting me no were,

what i need is to read in the current time from the system and split it out into hours mins and secs assigned to seperate variables,

i have been trying to use differant methods to do this but am not geting any were

We are talking windows api here? If so use GetSystemTime.

Code:
SYSTEMTIME time;
GetSystemTime(&time);

SYSTEMTIME is a structure, to get at the components do this

Code:
int iHours = time.wHour;
int iMinutes = time.wMinute;
int iSeconds = time.wSecond;
int iMilliSecondss = time.wMilliSeconds
 
Back
Top Bottom