23rd Apr 2021, 5:21 PM
Giriraj Yalpalwar
Giriraj Yalpalwar - avatar
3 Respostas
+ 3
The __TIME__ macro gives the time according to UTC. India is 5:30 hours ahead of UTC, so your code will output the time 5 hours and 30 minutes behind your local time (I don't know how you're getting 2h:30m back). To get the local time, first get the current time using the time() function of the <time.h> header. Then convert it to local time using the localtime() function. Note that this approach will not work on SoloLearn as SoloLearn runs the code on remote servers located somewhere in the world. So the code will output the time for that place. The simplest way to deal with this is to set the environment variable TZ to your timezone (Asia/Kolkata for India). Example: https://code.sololearn.com/csqx4ad2u3iF/?ref=app
23rd Apr 2021, 6:28 PM
XXX
XXX - avatar
+ 1
Thanks XXX for this , it is really helpful to understand about time My mistake for 2:30 it's actually 5:30 😀😀
23rd Apr 2021, 6:33 PM
Giriraj Yalpalwar
Giriraj Yalpalwar - avatar