Top "Python-datetime" questions

Python's built-in datetime module provides classes for manipulating dates and times in both simple and complex ways.

Getting today's date in YYYY-MM-DD in Python?

I'm using: str(datetime.datetime.today()).split()[0] to return today's date in the YYYY-MM-DD format. Is there a less crude …

python datetime python-datetime
Convert DataFrame column type from string to datetime, dd/mm/yyyy format

How can I convert a DataFrame column of strings (in dd/mm/yyyy format) to datetimes?

python pandas dataframe datetime-format python-datetime
Convert a python UTC datetime to a local datetime using only python standard library?

I have a python datetime instance that was created using datetime.utcnow() and persisted in database. For display, I would …

python datetime timezone python-datetime
Calculate Pandas DataFrame Time Difference Between Two Columns in Hours and Minutes

I have two columns, fromdate and todate, in a dataframe. import pandas as pd data = {'todate': [pd.Timestamp('2014-01…

python pandas datetime python-datetime
Python datetime strptime() and strftime(): how to preserve the timezone information

See the following code: import datetime import pytz fmt = '%Y-%m-%d %H:%M:%S %Z' d = datetime.datetime.…

python datetime python-datetime python-dateutil
How to convert a time string to seconds?

I need to convert time value strings given in the following format to seconds, for example: 1.'00:00:00,000' -> 0 …

python time python-datetime
How to convert integer into date object python?

I am creating a module in python, in which I am receiving the date in integer format like 20120213, which signifies …

python python-2.7 date python-datetime strptime
How do I determine if current time is within a specified range using Python's datetime module?

What would be the best way to see if the current time lies between say 10:30 AM and 4:30 PM. I could …

python python-datetime
Convert string into datetime.time object

Given the string in this format "HH:MM", for example "03:55", that represents 3 hours and 55 minutes. I want to convert it …

python time python-datetime
datetime.strptime(‘2017-01-12T14:12:06.000-0500’,'%Y-%m-%dT%H:%M:%S.%f%Z')

I've been trying to convert this specific date format to a string in Python like so: datetime.strptime(‘2017-01-12…

python python-2.7 datetime strptime python-datetime