-
Getting Time Problem
I want to get current time living in Turkey, but when I used following function getting time 3 hour less than our time because of that reason adding 3 to currentTime->tm_hour is there anything else I can do? Can I say compiler I am living turkey or some where else, is there any reference for that reason
Thanx u in advance.
time(&t);
currentTime = gmtime( &t);
currentTime->tm_hour = (currentTime->tm_hour +3 ) %24;
-
Use localtime instead of gmtime. When you call time, it returns your local machine time, say 8:00AM. When you are converting to GMT, since you live in Turkey, it needs to subtract 3 hours and it gives you back 5:00AM to which you are manually adding back those 3 hours. The solution is to not call gmtime. (At least that's what I think is happening in your case... not 100% sure)
-
Maybe use localtime() instead of gmtime() ?