0% found this document useful (0 votes)
6 views2 pages

Python Date and Time Operations Guide

Uploaded by

ASMA JAMAA
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Python Date and Time Operations Guide

Uploaded by

ASMA JAMAA
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

=============================Create Date ========================================

import datetime

d=[Link](2022,8,9)

print(d)

=========================Get current date ====================================

import datetime

d=[Link]()

print(d)

import datetime

d=[Link]()

print([Link])

print([Link])

print([Link])

import datetime

d=[Link]()

print([Link])

print([Link])

print([Link])

print([Link]())

print([Link]())

import datetime

d1=[Link](days=30)

d2=[Link]()

print(d2-d1)

==============================diff of tow dates (timedelta=============================

import datetime

d1=[Link](2020,8,20)

d2=[Link]()

print(type(d2-d1))

import datetime
t=[Link](11,45,30,999999)

print([Link])

print([Link])

print([Link])

=======================date after some days =====================================

import datetime

t=[Link](2020,3,13,12,30,40,9999)

dt=[Link](days=7)

print("after 7 days the date will be : ",(t+dt))

import datetime

d=[Link]()

d2=[Link]()

print(d)

print(d2)

========================Convert date to string =======================================

import datetime

d=[Link]()

print([Link]("%A, %b %d %Y,%I:%M %p")

========================Convert string to date ======================================

import datetime

dt_str="Monday, Nov 21 2022,07:44 PM"

dt_dt=[Link](dt_str,"%A, %b %d %Y,%I:%M %p")

print(dt_dt)

You might also like