Friday, 26 July 2013

Program to display Current Time Information

#include<iostream.h>
#include<math.h>
#include<time.h>
#include<conio.h>
void main()
{
    time_t p =time(0);
    tm* time=localtime(&p);
    clrscr();

    cout<<"Seconds= " << (time->tm_sec) <<endl;
    cout<<"Minutes = " << (time->tm_min) <<endl;
    cout<<"Hours = " << (time->tm_hour) <<endl;
    cout<<"Day of month = " << (time->tm_mday) <<endl;
    cout<<"Month of year = " << (time->tm_mon)+1 <<endl;
    cout<<"Year = " << (time->tm_year)+1900 <<endl;
    cout<<"Weekday = " << (time->tm_wday )<<endl;
    cout<<"Day of year = " << (time->tm_yday )<<endl<<endl<<endl;
    cout<<"Date     " <<(time->tm_mday)<<"/"<< (time->tm_mon)+1 <<"/"<< (time->tm_year)+1900<<endl;
    cout<<"Time     " << (time->tm_hour)<<":"<< (time->tm_min)<<":"<< (time->tm_sec) <<endl;
getch();
}

Here is the output:)


No comments:

Post a Comment