Getting current time of a different timezone using C++

后端 未结 4 1135
刺人心
刺人心 2021-01-05 05:17

How do i get the current time of a different time zone? Example, i need to know the current time in Singapore where as my system is set to PT time.

4条回答
  •  温柔的废话
    2021-01-05 06:14

    One implementation would be to use time to get the current time in UTC and then manipulate the TZ environment variable to your destination timezone. Then use localtime_r to convert to that timezone's local time.

提交回复
热议问题