Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

strptime

import datetime

date = '2021-01-01'
# For a datetime.datetime obj:
datetime.datetime.strptime(date, '%Y-%m-%d')
# For a datetime.date obj:
datetime.datetime.strptime(date, '%Y-%m-%d').date()
Comment

strp datetime

from datetime import datetime

date_string = "22 June, 2022"

print("date_string =", date_string)
print("type of date_string =", type(date_string))

date_object = datetime.strptime(date_string, "%d %B, %Y")

print("date_object =", date_object)
print("type of date_object =", type(date_object))
Comment

PREVIOUS NEXT
Code Example
Python :: python print with 2 decimals 
Python :: django response headers 
Python :: run for loop inside pdb 
Python :: calculate mean median mode in python 
Python :: embed image in html from python 
Python :: how to colour letters in python 
Python :: encrypt string with key python 
Python :: python panda append rows to csv python 
Python :: value_counts with nan 
Python :: how to use label encoding in python 
Python :: charts in python 
Python :: Python Changing Directory 
Python :: python pillow cut image in half 
Python :: install aws sdk python 
Python :: python to mac executable 
Python :: python constructor overloading 
Python :: how to sort a list descending python 
Python :: python find digits in string 
Python :: builtwith python 
Python :: how to install ffmpeg python heroku 
Python :: write a file python 
Python :: how to convert each string to a category or int in python dataframe 
Python :: jupyter notebook show full dataframe cell 
Python :: count consecutive values in python 
Python :: print in python without using print 
Python :: xticks and yticks matplotlib 
Python :: turtle star python 
Python :: pycountry 
Python :: length of string python 
Python :: import ndimage 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =