`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
6
votes
3 answers
How can I use datetime.strptime on a string in the format '0000-00-00T00:00:00+00:00'?
Due to my application's circumstances, I would prefer to use datetime.strptime instead of dateutil.parser.
After looking at the docs, I thought that %Y-%m-%dT%H:%M:%S%z may be the proper format for parsing a date string like this. Yet it still gives…

Jesse
- 69
- 1
- 7
6
votes
6 answers
Custom date format parsing in python
I am trying to the parse dates of the format '2016-04-15T12:24:20.707Z' in Python, tried strptime, doesn't work and I also tried django parse_datetime but it only returns none as the value

Amogha Varsha
- 89
- 1
- 1
- 8
6
votes
3 answers
strptime in Javascript
I have a date input field that allows the user to enter in a date and I need to validate this input (I already have server side validation), but the trick is that the format is locale dependent. I already have a system for translating the strptime…

mpeters
- 4,737
- 3
- 27
- 41
6
votes
1 answer
How can I get the max and min value of a datetime object
I have a csv file containing years of data, and I need to calculate the difference between two dates (the max date and the min date), so I believe that I should extract the max date and the min date.
Here's my data…

Mar
- 419
- 1
- 7
- 19
6
votes
1 answer
`DateTime.strptime` returns invalid date for weekday/time string
Why won't Ruby's strptime convert this to a DateTime object:
DateTime.strptime('Monday 10:20:20', '%A %H:%M:%S')
# => ArgumentError: invalid date
While these work?
DateTime.strptime('Wednesday', '%A')
# => #

Pavel K.
- 6,697
- 8
- 49
- 80
6
votes
3 answers
2 digit years using strptime() is not able to parse birthdays very well
Consider the following birthdays (as dob):
1-Jun-68
1-Jun-69
When parsed with Python’s datetime.strptime(dob, '%d-%b-%y') will yield:
datetime.datetime(2068, 6, 1, 0, 0)
datetime.datetime(1969, 6, 1, 0, 0)
Well of course they’re supposed to be…

casr
- 1,166
- 2
- 11
- 17
6
votes
1 answer
r strptime (R version 3.2.2 )
Using strptime for text strings with a "AM or PM" worked fine in R version 3.0.2
> strptime("8/25/2015 6:38:41 PM", "%m/%d/%Y %I:%M:%S %p")
[1] "2015-08-25 18:38:41"
I recently upgraded to R 3.2.2 and now find this commend returns a…

a_mcm
- 61
- 3
6
votes
2 answers
Temporarily change locale settings
Actual question
How can I temporarily change/specify the locale settings to be used for certain function calls (e.g. strptime())?
Background
I just ran the following rvest demo:
demo("tripadvisor", package = "rvest")
When it comes to the part where…

Rappster
- 12,762
- 7
- 71
- 120
6
votes
1 answer
strptime() function is undefined
I have a strange problem with strptime() function.
There is no php extension installation required in php manual and it is available in PHP 5 >= 5.1.0. I have installed wamp server on windows seven with php 5.3.5. but when I call this function it…

Mustafa Shujaie
- 806
- 2
- 10
- 18
5
votes
1 answer
strptime in c with timezone offsets
I'm having trouble finding a way to parse the timezone out of strings like the following:
"Thu, 1 Sep 2011 09:06:03 -0400 (EDT)"
What I need to do in the larger scheme of my program is take in a char* and convert it to a time_t.
The following is a…

VMills
- 183
- 3
- 4
- 12
5
votes
1 answer
How to parse str(my_datetime) using strptime?
This is the default string representation of a datetime:
>>> from datetime import datetime, timezone
>>> dt = datetime(2017, 1, 1, tzinfo=timezone.utc)
>>> print(dt)
2017-01-01 00:00:00+00:00
What is the correct format string to parse that with…

wim
- 338,267
- 99
- 616
- 750
5
votes
3 answers
Converting datetime from character to POSIXct object
I have an instrument that exports data in an unruly time format. I need to combine the date and time vectors into a new datetime vector in the following POSIXct format: %Y-%m-%d %H:%M:%S. Out of curiosity, I attempted to do this in three different…

philiporlando
- 941
- 4
- 19
- 31
5
votes
1 answer
How to make python datetime.strptime take into account timezone passed?
Trying to convert a string to datetime and save it to db. The string specifies the timezone, but strptime doesn't accept the %z option.
datetime.strptime("Tue Feb 14 2017 15:30:01 GMT-0500", "%a %b %d %Y %H:%M:%S GMT%z")
ValueError: 'z' is a bad…

Srini K
- 3,315
- 10
- 37
- 47
5
votes
4 answers
Converting to date in a character column that contains two date formats
I have CSV file with "date" column but it contains two different date format as the following
7/12/2015 15:28 as m/d/yyyy hh:mm
18-04-2016 18:20 as d/m/yyyy hh:mm
How can I change the format into m/d/yyyy hh: mm, So I can subtract the dates from…

Abdallah Khamash
- 53
- 3
5
votes
2 answers
alternative to strptime for comparing dates?
Is there any way to compare two dates without calling strptime each time in python? I'm sure given my problem there's no other way, but want to make sure I've checked all options.
I'm going through a very large log file, each line has a date which…

user1165419
- 663
- 2
- 10
- 21