Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python print time

import datetime
now = datetime.datetime.now()
print (now.strftime("%Y-%m-%d %H:%M:%S"))
# key: https://strftime.org/
Comment

print time python

import time
local_time = time.localtime()
time.strftime('%a, %d %b %Y %H:%M:%S', local_time)
Comment

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
Comment

how to get time in python

import datetime
 
currentDT = datetime.datetime.now()
print(str(currentDT))

# prints XXXX-XX-XX XX:XX:XX.XXXXXX
# or

import datetime
 
currentDT = datetime.datetime.now()
 
print ("Current Year is: %d" % currentDT.year)
print ("Current Month is: %d" % currentDT.month)
print ("Current Day is: %d" % currentDT.day)
print ("Current Hour is: %d" % currentDT.hour)
print ("Current Minute is: %d" % currentDT.minute)
print ("Current Second is: %d" % currentDT.second)
print ("Current Microsecond is: %d" % currentDT.microsecond)
# prints
"""
Current Year is: XXXX
Current Month is: XX
Current Day is: XX
Current Hour is: XX
Current Minute is: XX
Current Second is: XX
Current Microsecond is: XXXXXX
"""
Comment

PREVIOUS NEXT
Code Example
Python :: string hex to decimal python 
Python :: python abstract method 
Python :: load a Dictionary from File in Python Using the Load Function of the pickle Module 
Python :: python use variable in regex expression 
Python :: s = 1 + 2 + ... + n in python 
Python :: geometrical mean python 
Python :: pandas delete spaces 
Python :: radio button pyqt 
Python :: tkinter messagebox 
Python :: system to extract data from csv file in python 
Python :: finding the Unique values in data 
Python :: Palindrome Check using for loop in python 
Python :: how to get the first few lines of an ndarray 3d 
Python :: stack data horizontally pandas 
Python :: python timestamp to datetime 
Python :: how to make minecraft using python 
Python :: create an environment in conda 
Python :: seaborn bar plot dataset 
Python :: replace value in dataframe 
Python :: find the factorial of a given integer in python 
Python :: opencv dilate 
Python :: feature scaling in python 
Python :: how to check if a cell is empty in openpyxl 
Python :: python how to split a number 
Python :: reverse key order dict python 
Python :: accept user input in python 
Python :: np vstack 
Python :: how to resize windows in python 
Python :: smallest program to make diamond python 
Python :: # invert a dictionary 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =