In a Linux environment working in C++, I need to convert a time_t value into an English string representation for various time zones. e.g. 1305750080 -> "2011-05-18 13:21:20 PST". I am able to use gmtime() or localtime() combined with strftime() to generate strings for GMT and my local timezone. How would I select an alternative time zone?
gmtime() reference link here has an example showing a very simple way of applying time zone offsets. Naturally you could create a class with an enum or something and come up with something a little nicer.
Alternately boost::date_time has a pretty extensive implementation that works on linux and windows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With