Something About Date

This is a discussion on Something About Date within the C++ Programming forums, part of the General Programming Boards category; hi, i'm a new user. and i got some question about the date... is there any library function that can ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    2

    Question Something About Date

    hi, i'm a new user. and i got some question about the date...
    is there any library function that can count the days of a date?
    such as 1/1/2002 is 1st day of the year, then 1/2/2002 is the 32th days of the year ...

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Not that I know of, but it wouldn't be too hard to write either.

    Code:
    int month, days, prevdays, year;
    //input all the information
    switch (month)
    {   case 1:
            prevdays=0;
            break;
    
         case 2:
            prevdays=31
            break;
    //do the rest of the months, don't forget to check if it's leap year
    }
    
    cout<<"Number of days passed is "<<prevdays+days;

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    2

    Talking

    icic....
    it really help me a lot...
    thank you !!!

  4. #4
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Code:
    #include <ctime>
    #include <iostream>
    
    int main(int argc, char* argv[])
    {
    	using namespace std;
    	time_t currentTime = time(NULL);	
    	struct tm *timeInfo = localtime(&currentTime);
    
    	cout << timeInfo->tm_yday;
      
    	return 0;
    }
    Check all the other members of the tm structure for other neat measures of time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Advancing day by day until it matches a second date
    By nhubred in forum C++ Programming
    Replies: 1
    Last Post: 05-30-2009, 08:55 AM
  2. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  3. Date program starts DOS's date
    By jrahhali in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2003, 04:23 PM
  4. CDate Class - handle date manipulation simply
    By LuckY in forum C++ Programming
    Replies: 5
    Last Post: 07-16-2003, 08:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21