Q: Obtaining the time when a program was compiled in C/C++/Obj-C I have developed a simple utility for my iPhone and iPad apps which places a small watermark view in the bottom right corner of the app showing the bundle version, and indicating that the app is still in development (You'd be amazed how many clients get given a test version as part of the agile process, show it to their colleagues without telling them it is a test version, and we get flak because of it).
As part of this, I would like to include the date that that particular build of the app was compiled. For example, if I compiled it at 8.53 AM on Monday the 24th of September, 2012, it would say just that on the watermark. In the course of a day, I often send out many builds to many people, fixing lots of small issues, especially in the later stages of development when I am tweaking UI and polishing. It would be rather helpful to be able to compare the date of a build against version control messages and suchlike, as often different testers will report on fixed issues. There is not much point incrementing version numbers for simple things like shifting a label, or correcting spelling typo's, until a good days work is done.
Now that you have my motivation, I was wondering if there is a way to set, at compile time, the time when compilation occured. I am hoping it is some sort of C macro I can set to assign the value to a variable.
Does anyone know if this is possible or not.
Thanks in advance.
EDIT: I found it. I cannot believe none of my other googles turned this up. Typical it is found right after I ask the question. For anyone interested, it is this code. Or, if an admin wants to remove this as frivolous, that's fine too :)
NSLog(@"%s %s %s",__DATE__, __TIME__, __TIMESTAMP__);


A: In C, the predefined macro names __TIME__ and __DATE__ expand to string literals containing the compilation time and date respectively.
