Results 1 to 3 of 3

Thread: getting current year

  1. #1

    Thread Starter
    Hyperactive Member wordracr's Avatar
    Join Date
    Aug 2001
    Posts
    281

    getting current year

    is there some way to do this with ctime?
    I have included ctime, and I created a ctime variable for storing the current time, CTime theTime;
    but I get an error "CTime undeclared identifier".
    Also, is there anyway to seperate the year from the returned value?

    Thank you!!

  2. #2
    amac
    Guest
    Where are you trying to use this??? Are you creating an MFC app? Or using MFC? Becuase CTime is a MFC class.

  3. #3
    amac
    Guest
    If you don't wanna use MFC, there is always this option...


    Code:
            struct tm * tmTime = NULL;
            time_t tTimeInt = 0;
    
            time(  &tTimeInt );        
            tmTime = localtime( &tTimeInt );
    
            tmTime->tm_year;   // This is the current year  
                                            // minus 1900.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width