`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
5
votes
1 answer
ValueError time data 'Fri Mar 11 15:59:57 EST 2016' does not match format '%a %b %d %H:%M:%S %Z %Y'
I am trying to simply create a datetime object from the following date: 'Fri Mar 11 15:59:57 EST 2016' using the format: '%a %b %d %H:%M:%S %Z %Y'.
Here's the code.
from datetime import datetime
date = datetime.strptime('Fri Mar 11 15:59:57 EST…

Jonathan Freed
- 63
- 5
5
votes
3 answers
python strptime correct format for sub seconds
My datetime data is like this:
2016-03-01 19:25:53.053404
I am trying to use
datetime.strptime(date, "%Y-%m-%d %HH:%MM:%SS")
But I get this error:
ValueError: time data '2016-03-01 19:24:35.165425' does not match format '%Y-%m-%d…

apadana
- 13,456
- 15
- 82
- 98
5
votes
1 answer
How do I specify POSIX (time) format for 3 letter tz in R, in order to ignore it?
For output, the specification is %Z (see ?strptime). But for input, how does that work?
To clarify, it'd be great for the time zone abbreviation to be parsed into useful information by as.POSIXct(), but more core to be question is how to get the…

rbatt
- 4,677
- 4
- 23
- 41
5
votes
3 answers
Python, strptime is skipping zeros in the millisecond section
I want to extract the timestamp from a string, but the milliseconds part is not being read properly
datetime.strptime('20130629110924095','%Y%m%d%H%M%S%f')
produces the following output
datetime.datetime(2013, 6, 29, 11, 9, 24, 95000)
instead…

tokyoCoder
- 81
- 8
5
votes
3 answers
Converting string to date with Ruby
I have date as string in such format: 23 Nov. 2014. Sure, it's easy to convert this string into date with such expression:
Date.strptime(my_string, '%d %b. %Y')
But there is one issue when month is May - there is no dot, like 23 May 2014. And my…

ktaras
- 407
- 4
- 16
5
votes
1 answer
Ruby Date.strptime doesn't enforce 4-digit year
I would expect this code to give me an ArgumentError: invalid date error. In Ruby 2.0.0 irb:
irb(main):003:0> Date.strptime('05-10-2014', '%Y-%m-%d')
=> #
Am I doing something wrong or will Ruby…

J Graham
- 181
- 1
- 7
5
votes
1 answer
c/c++ strptime() does not parse %Z Timezone name
I am new to C. When I practicing C to covert time sting to structure tm back and forth. I noticed some difference. Please advice what I did wrong.
#include
#include
#include
/*
test different format string to…

Albert
- 53
- 1
- 3
5
votes
1 answer
C : Validation in strptime
strptime() function in C fails to detect invalid dates. Ex: 2011-02-31 , 2011-04-31.
Is there any other function or workaround to this problem

Andy Stow Away
- 649
- 1
- 8
- 17
4
votes
2 answers
strptime example for datetime with tz offset
I have the datetime string 2020-10-23T11:50:19+00:00. I can parse it without the timezone as:
>>> datetime.strptime('2020-10-23T11:50:19', '%Y-%m-%dT%H:%M:%S')
datetime.datetime(2020, 10, 23, 11, 50, 19)
But I'm having trouble parsing it with the…

David542
- 104,438
- 178
- 489
- 842
4
votes
2 answers
ISO time to Human readable time in python
I am using Python. My time format is like
2020-05-23T06:35:11.418279Z #May 23, 2020 at 12:05:11 PM GMT+05:30
I want to convert into human readable time like
23-05-2020 12:05 PM
I tried parser too. But no effect.
Can anyone help me with…

codebuff
- 93
- 3
- 15
4
votes
1 answer
How to convert dataframe column with datetime value to ISO-8601 time format with timezone?
How can I convert all dataframe column value to ISO-8601 format
Given below the sample value I get, when I execute print(df['timestamp']) for reference
0 2020-02-03 18:00:33
1 2020-02-03 18:00:37
2 2020-02-03 18:00:39
3 2020-02-03 18:01:16
4…

Sunish
- 77
- 3
- 12
4
votes
2 answers
Converting string dates, which may not be padded by zeros
I am getting my data and some dates from an unconventional source and because of this there are some minor differences in the string dates. the big difference is that there are dates mixed in where the day is not padded by a zero, there can be a…

mitch
- 379
- 1
- 3
- 14
4
votes
3 answers
convert to date and strip time?
I have some data that looks like this:
dates <- structure(c(1L, 2L, 4L, 3L), .Label = c("Sat, 18 Nov 2017 00:00:00 GMT",
"Thu, 16 Nov 2017 00:00:00 GMT", "Tue, 14 Nov 2017 00:00:00 GMT",
…

Ignacio
- 7,646
- 16
- 60
- 113
4
votes
2 answers
Fixed strptime exception with thread lock, but slows down the program
I have the following code, which when is running inside of a thread (the full code is here - https://github.com/eWizardII/homobabel/blob/master/lovebird.py)
for null in range(0,1):
while True:
try:
…

eWizardII
- 1,916
- 4
- 32
- 55
4
votes
1 answer
TypeError: strptime() argument 1 must be string, not float
Good morning!
I have a series of events with associated dates. The event dates are stored as a series of string values in a column within a dataframe that I have loaded into Python. The dataframe contains other columns with values. I would like to…

ailsa_naismith
- 333
- 2
- 4
- 15