Time and date in C

Discussion in 'Mac Programming' started by Quboid, Apr 30, 2007.

  1. Quboid macrumors 6502

    Joined:
    Oct 16, 2006
    Location:
    everywhere
    #1
    Hey people,

    so far I haVe been advancing in my programing by finding function syntax on hte net and using logic to get through the rest. But I am in the middle of a cinema program and I am stuck in my ticket sales functions cause I can't (no matter how hard i try) to figure out how to use the "current time" (using getdate or whatever tha appropriate function is) in my program.
    For the record i am going to use the time to subtract a discount to the buyer depending on the time of day of the movie. I really need help on this on, thanks, i appreciate it.

    Q
     
  2. kpua macrumors 6502

    Joined:
    Jul 25, 2006
  3. pilotError macrumors 68020

    pilotError

    Joined:
    Apr 12, 2006
    Location:
    Long Island
    #3
    Code:
     
     time_t now;
     struct tm *localTime;
    
    	time( &now );
    
    	localTime = localtime( &now );  /* Convert time to struct */
    
            printf("Time is now: %s", asctime( localTime ));
    
     

Share This Page