To include in your arduino code, use these lines near the top of your program.
// get date and time of compile...
char compileDATE[] PROGMEM = __DATE__;Then, to use it in your program, include the array in a print statement.
char compileTIME[] PROGMEM = __TIME__;
Serial.println(compileTIME);
prints: 20:38:56
Or, in a formatted print string using printf(),
compileDATE[3] = '.'; // replace spaces
compileDATE[6] = '.';
Serial.printf("Date %s Time %s", compileDATE, compileTIME);
prints: Date Oct.20.2015 Time 20:38:56