Use datetime.datetime.strptime()
and call .time()
on the result:
>>> datetime.datetime.strptime('03:55', '%H:%M').time()
datetime.time(3, 55)
The first argument to .strptime()
is the string to parse, the second is the expected format.
More Related Contents:
- How to calculate the time interval between two time strings
- How to convert a time string to seconds?
- How do I get the current time?
- How do I get the day of week given a date?
- how to sort pandas dataframe from one column
- Python’s time.clock() vs. time.time() accuracy?
- What is the standard way to add N seconds to datetime.time in Python?
- Display the time in a different time zone
- Tkinter — executing functions over time
- Python regex match OR operator
- High-precision clock in Python
- How to add delta to python datetime.time?
- Does Python’s time.time() return the local or UTC timestamp?
- Python module to change system date and time
- Python: give start and end of week data from a given date
- Python daylight savings time
- How to get current time in python and break up into year, month, day, hour, minute?
- python date of the previous month
- Calculating Time Difference
- How do you calculate program run time in python? [duplicate]
- Using %f with strftime() in Python to get microseconds
- Python time measure function
- How to convert integer into date object python?
- Get POSIX/Unix time in seconds and nanoseconds in Python?
- How to get the seconds since epoch from the time + date output of gmtime()?
- How to make a datetime object aware (not naive) in Python?
- How to convert epoch time with nanoseconds to human-readable?
- Equivalent to GetTickCount() on Linux
- Upper limit in Python time.sleep()?
- Python logging: use milliseconds in time format