Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python current date and time

from datetime import datetime

# datetime object containing current date and time
now = datetime.now()
 
print("now =", now)

#Output: now = 2021-06-25 07:58:56.550604

# dd/mm/YY H:M:S
dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
print("date and time =", dt_string)

#Output: date and time = 25/06/2021 07:58:56
Comment

pythom datetime now

>>> from datetime import datetime
>>> datetime.today().strftime('%Y-%m-%d')
'2021-01-26'
Comment

Python program to display the current date and time


import datetime
now = datetime.datetime.now()
print ("Current date and time : ")
print (now.strftime("%Y-%m-%d %H:%M:%S"))				 
	
Comment

pythom datetime now

>>> from datetime import datetime
>>> datetime.today().strftime('%Y-%m-%d')
'2021-01-26'
Comment

PREVIOUS NEXT
Code Example
Python :: command prompt pause in python 
Python :: django all urls 
Python :: main arguments python 
Python :: set the root directory when starting jupyter notebooks 
Python :: pyaudio install error ubuntu 
Python :: ImportError: No module named pip --Windows 
Python :: python change cmd title 
Python :: finding the format of an image in cv2 
Python :: spacex 
Python :: print a random word from list python 
Python :: python version check 
Python :: plot bounds python 
Python :: how to subtract dates in python 
Python :: colab read xlsx 
Python :: python file name from absolute path 
Python :: how to change the color of command prompt in python 
Python :: dataframe delete row 
Python :: Entry border color in tkinter 
Python :: python backward difference 
Python :: how to get the mouse input in pygame 
Python :: python numpy kurtosis 
Python :: python dedent 
Python :: resample python numpy 
Python :: read xls file in python 
Python :: random list python 
Python :: blender python save file 
Python :: how to plotting horizontal bar on matplotlib 
Python :: python number to letter 
Python :: pandas query on datetime 
Python :: python random choice int 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =