__TIMESTAMP__

__TIMESTAMP__

__TIMESTAMP__ is a preprocessor macro that expands to current time (at compile time)
in the form Ddd Mmm Date hh::mm::ss yyyy, where the time is in 24 hour
time, Ddd is the abbreviated day, Mmm is the abbreviated month, Date is the
current day of the month (1-31), and yyyy is the four digit year. For
example "Wed Jan 18 22:29:12 2012". The __TIMESTAMP__ macro can be used to
provide information about the particular moment a
binary was built.

void printBuildDateTime ()
{
cout << __TIMESTAMP__ << endl;
}

You can also use the __DATE__ macro to get the current date, or the __TIME__ macro to get the current time.