Solaris timezone in C (% z missing on strftime)

I have an application that writes to another application and should provide the date + time zone of the system. I used strftime with the% z argument to get the timezone, and it works fine on Linux. However, last week we decided to merge it with Solaris to find out that% z is not.

Someone suggested using% Z, which gives the name of the time zone, but I need% z, which gives the time zone with an offset format, like +0100 or -0300 ...

Does anyone have any idea?

+1
c solaris strftime
source share
1 answer

% z is not POSIX. You will need to calculate the offset yourself by finding the difference between localtime and gmtime.

For an example of Perl, see here .

+2
source share

All Articles