Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python year month day hour minute second

import datetime
date = '2021-05-21 11:22:03'
datem = datetime.datetime.strptime(date, "%Y-%m-%d %H:%M:%S")
print(datem.day)        # 25
print(datem.month)      # 5
print(datem.year)       # 2021
print(datem.hour)       # 11
print(datem.minute)     # 22
print(datem.second)     # 3
Comment

get month day year 12 hour time format python

import time

# get current time
date_time = time.strftime("%b %d, %Y %-I%p")

#the above outputs: May 27, 2021 7PM
Comment

PREVIOUS NEXT
Code Example
Python :: Select rows in pandas MultiIndex DataFrame 
Python :: drop rows from dataframe based on column value 
Python :: python profiler 
Python :: how to convert a set to a list in python 
Python :: delete database entry using name django 
Python :: how to make an ai 
Python :: how to open a website using python 
Python :: render django 
Python :: user input python 
Python :: getting started with machine learning 
Python :: call a function onclick tkinter 
Python :: path to create a text file in python 
Python :: python check if array is subset of another 
Python :: requests.packages.urllib3.util.retry could not be resolved from source 
Python :: python if in list multiple 
Python :: how to print all elements of a dictionary in python 
Python :: 2d gaussian function python 
Python :: pandas add quantile columns 
Python :: debug mode: on flask pythin window 
Python :: how to sort a dictionary using pprint module in python 
Python :: socket io python 
Python :: How to store password in hashlib in python 
Python :: doc2vec similarity 
Python :: effektivwert python 
Python :: import get_object_or_404 
Python :: pygame tick time 
Python :: python stop while loop after time 
Python :: how to define the name of your tkinter window 
Python :: odd or even python 
Python :: for one line python 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =