Incorrect Localtime? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Incorrect Localtime?

When I tried accessing the time (I live in Germany) via localtime function, I noticed that it is in fact two hours behind my current time. Shouldnt it return my current time, or did I mistake something? Or is there a different explanation?

24th Oct 2017, 8:39 PM
Shadow
Shadow - avatar
3 Answers
+ 5
Where did you run the code? In your PC or the Sololearn Compiler? The Sololearn's Server Computer, where our codes compile, has the UTC Time Zone.
25th Oct 2017, 12:36 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 4
According to WorldTimeServer German timezone is UTC+2 (two hours faster) https://www.worldtimeserver.com/current_time_in_DE.aspx I can only suggest to lookup for timezones information and related functions for translation of UTC/GMT to your local timezone.
24th Oct 2017, 9:40 PM
Ipang
+ 1
@Kinshuk, yes, as I have no access to my laptop atm, I used this app to compile. Well, that explains why localtime was similar to UTC time too, I suppose. I already thought I mistook something about the use of localtime, thanks a lot! I'll try it in Code::Blocks then as soon as I can...
25th Oct 2017, 6:47 AM
Shadow
Shadow - avatar