Use gmtime_r() instead of gmtime().