0

Date in Python?

How do I get date from python like 1pm when it is 1pm?

3rd Nov 2018, 1:22 AM
Vanessa Nilsson
4 Respuestas
+ 7
from datetime import datetime # both time & date print(datetime.now()) # only date print(datetime.now().date()) # only time print(datetime.now().time()) # hh:mm:ss AM/PM format print(datetime.now().strftime("%I:%M:%S %p")) Check out the docs for more: https://docs.python.org/3/library/datetime.html
3rd Nov 2018, 2:01 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 6
Kishalaya has answered well, just notice that on SoloLearn, the time will be of SoloLearn's server but not your device, because codes are executed there and then return the result to ours
3rd Nov 2018, 2:38 AM
Flandre Scarlet
Flandre Scarlet - avatar
+ 1
You're welcome, Skrub !
3rd Nov 2018, 2:31 AM
Kishalaya Saha
Kishalaya Saha - avatar
0
thanks
3rd Nov 2018, 2:25 AM
Vanessa Nilsson