This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Setting Time Zone for __DATE__ & __TIME__

The macros __DATE__ & __TIME__ are displaying GMT. How can I get them to display
local time (EST)?

Time is displayed correctly everywhere else. The laptop is running Windows 7 64-bit.

Parents
  • The preprocessor macros are pretty basic; not sure I've ever seen them support timezones. Almost note that they are not particularly well defined (it's not part of the C standard at all - just a commonly supported extension), so whatever you end up with is likely to be non-portable.

    Options:

    • Option 1: Define a custom "MY_TIME" macro and get your build system to generate a string in whatever time format / timezone you want.
    • Option 2: Parse the string from __TIME__ at runtime (see above comment on portability issues).

    HTH,
    Pete

Reply
  • The preprocessor macros are pretty basic; not sure I've ever seen them support timezones. Almost note that they are not particularly well defined (it's not part of the C standard at all - just a commonly supported extension), so whatever you end up with is likely to be non-portable.

    Options:

    • Option 1: Define a custom "MY_TIME" macro and get your build system to generate a string in whatever time format / timezone you want.
    • Option 2: Parse the string from __TIME__ at runtime (see above comment on portability issues).

    HTH,
    Pete

Children
No data