GCC get build date and time in local timezone

1.6k Views Asked by At

GCC provides the macros __DATE__ and __TIME__ that give string constants with the build date and time. However they seem to be giving the time in UTC. Is there some macro to get the build time in local time zone?

1

There are 1 best solutions below

1
Andrey My On

Some gcc compilers have such behavior - macros __TIME__ outputs an UTC time, not local. I've seen such effect with arm-linux-gnueabihf-gcc from Xilinx petalinux generated sdk. You can verify your compiler using command line suggested by Vladislav Ivanishin (see comments).

UPD: By request from comment below I've added link to the Vladislav Ivanishin's comment: GCC get build date and time in local timezone

And the command line to verify gcc is: echo __TIME__ | gcc -E -xc - | tail -1