Parse the string to datetime in Python (datetime.strptime)
In Python, `strptime` parses a string to a datetime object. python import datetime t = datetime.datetime.strptime('Aug 7 2019', '%b %d %...
Python datetime and timezone - How to get the local datetime
The best way to get the local time is using pytz module. python import datetime import pytz zone_ny = pytz.timezone('America/New_York...
Python timedelta - How to add minutes or hours to the current time
We can get the future date or time to use Python `timedelta` method. Before using that, let's import `datetime` and `timedelta` from `datetime`....
Python timestamp: How to get the current Unix timestamp
In Python, `time` function in `time` module returns the current Unix timestamp. python import time t = time.time() print(t) # 160050...
Python calendar: How to check if this year is leap year in Python
In Python, we can easily check if a year is leap or not importing calendar and using function `isleap`. python import calendar i = calen...
Python: What day of the week today?
Today (2020-09-19) is Saturday but how can we get the value in Python? Before explaining, let's see Python calendar package. python import ...
How to get today's year, month, day in Python
We can get today's date by importing `datetime`. python import datetime today = datetime.date.today() print(today) # 2020-09-19 pri...
Python String
Python List
Python Tuple
Python Set
Python Dictionary
Python Float
Python Decimal
Python Fraction
Python Date & Time
Python Function
Python Class
Python File
Python Built in
Python Math
Python Counter
Python Functools
Python Itertools
Python Deque
Python Tips
© Rollpie