Answers for "python actual time"

7

python show current time

from datetime import datetime

now = datetime.now()

current_time = now.strftime("%H:%M:%S")
print("Current Time =", current_time)
Posted by: Guest on April-29-2020
7

get current time python

from datetime import datetime as d
import time as t
from os import system as clear
cls = lambda: clear("clear")

prev = d.now()
prev = prev.strftime("%Y-%m-%d %H:%M:%S")

while True:
  time = d.now()
  time = time.strftime("%Y-%m-%d %H:%M:%S")
  print(time)
  if not time == prev:
    prev = time
  t.sleep(1)
  cls()
Posted by: Guest on December-15-2020
3

python get current time

---------------------------------------------------------
import datetime
 
currentDateTime = datetime.datetime.now()
print(currentDateTime)
---------------------------------------------------------
OR
---------------------------------------------------------
from datetime import datetime
 
currentDateTime = datetime.now()
print(currentDateTime)
---------------------------------------------------------
OR
---------------------------------------------------------
import datetime

print(datetime.datetime.now())
---------------------------------------------------------
OR
---------------------------------------------------------
from datetime import datetime
 
print(datetime.now())
---------------------------------------------------------
Posted by: Guest on February-16-2021
3

how to print time python

import datetime
datetime.datetime.now()
datetime.datetime(2009, 1, 6, 15, 8, 24, 78915)

print(datetime.datetime.now())
#2009-01-06 15:08:24.789150
Posted by: Guest on June-02-2020

Python Answers by Framework

Browse Popular Code Answers by Language