Getting the Current Date and Time - C++ Data Type

C++ examples for Data Type:time

Description

Getting the Current Date and Time

Demo Code

#include <ctime>
#include <chrono>
#include <iostream>

using namespace std;
using namespace chrono;

int main()//from w  w w.  jav  a 2  s .  c  o m
{
    auto currentTimePoint = system_clock::now();
    auto currentTime = system_clock::to_time_t( currentTimePoint );
    auto timeText = ctime( &currentTime );

    cout << timeText << endl;

    return 0;
}

Result


Related Tutorials