Using _strtime and _strdate to get the time

This tip submitted by Ali Jafar on 2011-09-16 14:49:58. It has been viewed 17816 times.
Rating of 5.9 with 357 votes

You Can make clock in C++ by using _strtime and also get current date by using _strdate


using namespace std;

int main( )
    char dateStr [9];
    char timeStr [9];
    cout<< "The current date is  " << dateStr ;
    _strtime( timeStr );
    cout << "\nThe current time is "<

For security sensitive programs, consider using _strtime_s and _strdate_s instead.

More tips

Help your fellow programmers! Add a tip!