Could someone help me to get correct current time in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Could someone help me to get correct current time in python

from datetime import datetime Print(str(datetime.now()) Executing above two lines ,it prints some other time than current time in my zone. My cell has correct updated time in my zone where I am executing these lines. I executed above lines in code playground. could someone please help me to get correct time.

9th Nov 2019, 2:12 PM
Banana Face
Banana Face - avatar
3 Answers
+ 4
you have to understand that the code you wrote is being executed on a server and it returns its time as output . nothing is being executed on your phone.
9th Nov 2019, 3:04 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 1
Your code is correct only.. This code do not work in sololearn. Because this were connected to sololearn server.. You can try in pydroid3 app..
11th Nov 2019, 3:16 AM
Dilji
Dilji - avatar