Time zone information of other countries

Dear all,

Could anyone tell me how to get time zone information of other countries rather than the timezone of the program running?

I know how to get the timezone of the program running, which is:

TIME_ZONE_INFORMATION tzi;
GetTimeZoneInformation(&tzi);

But I am now wanting time zone of other countries, such as USA/EST.

Thanks!
You may need to modify for daylight savings time changes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* gmtime example */
#include <stdio.h>
#include <time.h>

#define PST (-7)
#define MST (-6)
#define CST (-5)
#define EST (-4)
#define UTC (0)
#define BST (+1)
#define CCT (+8)

int main ()
{
  time_t rawtime;
  struct tm * ptm;

  time ( &rawtime );

  ptm = gmtime ( &rawtime );

  puts ("Current time around the World:");
  printf ("Pacific Time   (UTC-7)\t :  %2d:%02d\n", (ptm->tm_hour+PST)%24, ptm->tm_min);
  printf ("Mountain Time  (UTC-6)\t :  %2d:%02d\n", (ptm->tm_hour+MST)%24, ptm->tm_min);
  printf ("Central Time   (UTC-5)\t :  %2d:%02d\n", (ptm->tm_hour+CST)%24, ptm->tm_min);
  printf ("Eastern Time   (UTC-4)\t :  %2d:%02d\n", (ptm->tm_hour+EST)%24, ptm->tm_min);
printf ("\n");
  printf ("Universal Time (UTC0) \t :  %2d:%02d\n", (ptm->tm_hour+UTC)%24, ptm->tm_min);
printf ("\n");
  printf ("London England (UTC+1)\t :  %2d:%02d\n", (ptm->tm_hour+BST)%24, ptm->tm_min);
  printf ("Beijing China  (UTC+8)\t :  %2d:%02d\n", (ptm->tm_hour+CCT)%24, ptm->tm_min);
  
  return 0;
}
Last edited on
Topic archived. No new replies allowed.