1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

C++ Date and Time questions

Discussion in 'HTML, Graphics & Programming' started by Dr Zoidberg, 17 Jun 2006.

  1. Dr Zoidberg

    Hitman

    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
     
  2. yhack

    Mobster

    Joined: 6 Jan 2005

    Posts: 3,636

    Location: Cambridge

  3. Dr Zoidberg

    Hitman

    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
     
  4. Una

    Wise Guy

    Joined: 26 Nov 2004

    Posts: 2,471

    Location: Reading / Lake District

  5. Lithium UK

    Associate

    Joined: 30 May 2006

    Posts: 70

    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
     
  6. Dr Zoidberg

    Hitman

    Joined: 18 Oct 2002

    Posts: 710

    Location: Somerset

    Ended up just useing 'Now' assigned to the relavent object and all is working fine,

    Thanks for all the help,