Here is an example to get current date and time in C++ language,
Example
#include <iostream>
using namespace std;
int main() {
time_t now = time(0);
char *date = ctime(& now);
cout << "The local date and time : " << date << endl;
}Output
Here is the output
The local date and time : Wed Oct 3 08:35:24 2018
In the above program, the code to get current date and time is present in main(). Here, time_t is the return type of variable now. In-built function time() is used to get the local current time and date.
time_t now = time(0); char *date = ctime(& now);