Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have an application that writes to another application and needs to provide the date + timezone of the system. I have been using strftime with the %z argument to get the timezone, and it has been working very well on Linux. However, last week we decided to merge it to solaris just to find out that %z is not present.

Someone suggested to use %Z, which will give the timezone name, but I need the %z which gives the timezone with the offset format, like +0100 or -0300 ...

Anyone has ideas?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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

For a Perl example, see here.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.