`strptime` reads the time from the string s using the timeformat specifiers and converts it into seconds since the year 2000.
Questions tagged [strptime]
779 questions
2
votes
2 answers
Python strptime not parsing time zone EST %z
I am trying to parse the string '10/23/2019 6:02:05 PM EST' into a datetime with time zone using Python 3.7.
Code:
from datetime import datetime
timestamp = datetime.strptime(date_str, '%m/%d/%Y %I:%M:%S %p %Z')
Error:
ValueError: time data…

wjw
- 209
- 2
- 6
2
votes
2 answers
How to provide default time when using datetime.strptime?
I'm using datetime.strptime to parse and obtain DateTime values from strings, in the form of %Y-%m-%dT%H:%M:%SZ but the data is dirty and sometimes doesn't have the time parameter, is sometimes received in yyyy/mm/dd format instead of yyyy-mm-dd…

Hyuga Hinata
- 47
- 8
2
votes
2 answers
format 01-01-16 7:43 string to datetime
I have the following strings that I'd like to convert to datetime objects:
'01-01-16 7:43'
'01-01-16 3:24'
However, when I try to use strptime it always results in a does not match format error.
Pandas to_datetime function nicely handles the…

hk_03
- 192
- 3
- 12
2
votes
3 answers
R strptime issue when using %b to format a date
Before marking as duplicate, I've tried a few other solutions, namely these:
R, strptime(), %b, trying to convert character to date format
strptime, as.POSIXct and as.Date return unexpected NA
But neither seem to work for me.
I'm trying to convert…

giraffehere
- 1,118
- 7
- 18
2
votes
1 answer
ValueError: time data '2018-12-22T00:41:30.926932Z' does not match format '%Y-%m-%d %H:%M:%S'
I'm having troubles converting a time string to datetime object:
And i know this question has been asked a couple of times but i haven't been able to find a solution for my question.
Here is my code:
order['created'] =…

David Ramirez
- 382
- 2
- 6
- 14
2
votes
1 answer
strptime different output in python 2.7 compared to python 2.3 and Excel
I have some python 2.3.4 scripts to migrate to python 2.7.5 and I found a strange issue in the behavior of strptime.
The Script Sample convert a string in (week number, day, year) format to a datetime:
dw='51 0 18' # 51 week number , 0 for Sunday…

adel
- 95
- 5
2
votes
2 answers
Python Datetime object
I am currently having an issue converting an incoming datetime string to a datetime object using Python's built in strptime() method. Here is what I currently have:
def fixDateTimeField(datetimeString):
# Convert from 2012-08-07T00:00:00Z to…

Scott
- 697
- 8
- 18
2
votes
1 answer
how to set the day, month and year in a posixlt in r?
i have to fix a date in a data frame. the date comes in as "16/12/2006", and the time comes in as "17:24:00". i want to construct a posixlt with the combined date and time. i tried:
fixTime2<-function(date,time) { # replaces the date in time with…

Ray Tayek
- 9,841
- 8
- 50
- 90
2
votes
1 answer
How to convert mm:ss.ms to ss.ms?
I'm trying to make a conversion for below example:
original time: 1:03.091
converted time: 63.09
I did some research and found that I can add up the min to secs, but don't know how to add the milliseconds anymore. Below is what I've managed to do so…

Penny
- 1,218
- 1
- 13
- 32
2
votes
2 answers
Issues while converting data in strptime in python
I'm trying to calculate average time distance from a point to another. This is the functions for the import data.
While handling the time there is an error about the type list of the start time
stime_record :
[['01/01/2016 00h15m'], ['01/01/2016…

DeboraID
- 39
- 5
2
votes
3 answers
How exactly is the %y directive interpreted when parsing dates?
While reading this question about parsing dates of the form %m/%d/%y, I realized that I don't know how the %y directive actually works.
The docs state the following:
Year without century as a zero-padded decimal number.
But which century does it…

Aran-Fey
- 39,665
- 11
- 104
- 149
2
votes
0 answers
How to parse Python datetime.str output with strptime?
I am getting timestamps from a REST server which creates them using datetime.str(). This gives me a timestamp that looks like: '2018-02-21 10:40:35+00:00'. However, datetime.strptime only supports %z which requires the trailing timezone offset to be…

PaulMcG
- 62,419
- 16
- 94
- 130
2
votes
0 answers
Python datetime.strftime and datetime.strptime
I was reading a chapter on datetime from 'Effective Python' and stumbled upon this strange behavior of datetime.strptime: it raises a ValueError on the very string formatted with datetime.strftime using the same format. if I remove the timezone…

Xiaotian Guo
- 1,635
- 3
- 17
- 21
2
votes
1 answer
Convert different date-time-formats at once (strptime)
Hi :) I have a column of my data.frame which contains dates in two formats. Here is an short minimal example:
D = data.frame(dates = c("3/31/2016", "01.12.2015"))
dates
1 3/31/2016
2 01.12.2015
With the nice function strptime I can easily…

Marco
- 2,368
- 6
- 22
- 48
2
votes
2 answers
Converting timestamp in seconds to a date format in R
I have a table (tags) with a column for timestamp (ts), which is formatted as seconds since 1 Jan, 1970 GMT. I'm trying to create a date column that converts the timestamp from seconds to date and time EST.
The suggested code for R…

D.K.
- 21
- 1