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 31421 times.
Rating of 5.7 with 426 votes



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

#include 
#include 

using namespace std;

int main( )
{
    char dateStr [9];
    char timeStr [9];
    _strdate(dateStr);
    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!