Questions tagged [strptime]

`strptime` reads the time from the string s using the timeformat specifiers and converts it into seconds since the year 2000.

779 questions
3
votes
2 answers

datetime TypeError: 'datetime.datetime' object has no attribute '__getitem__'

What am I doing wrong here? import datetime someday = datetime.datetime(2014, 9, 23, 0, 0) someday = datetime.datetime.strptime(someday[:10], '%Y-%m-%d') print someday Error: TypeError: 'datetime.datetime' object has no attribute '__getitem__'
user2242044
  • 8,803
  • 25
  • 97
  • 164
3
votes
1 answer

Python 3.4 strptime() not working

I am trying to convert a string to datetime and it isn't working... self.loadsList[loadID][5] = datetime.strptime( self.loadsList[loadID][5]+" "+self.loadsList[loadID][6], "%x %X %z") and it raises a Value Error. ValueError: time data '11/08/2014…
3
votes
2 answers

Why %z is not supported by python's strptime?

>>> datetime.strptime('2014-02-13 11:55:00 -0800', '%Y-%m-%d %H:%M:%S %z') Traceback (most recent call last): File "", line 1, in File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_strptime.py", line…
wanghq
  • 1,336
  • 9
  • 17
3
votes
2 answers

Perl strptime format differs from strftime

I'm trying to work with date strings formatted as: YYYY-MM-DDThh:mm:ss strftime format for generating this string is %FT%T: perl -MPOSIX=strftime -E 'say strftime q{%FT%T}, localtime;' But when I try to parse this date string with…
Suic
  • 2,441
  • 1
  • 17
  • 30
3
votes
3 answers

c++ strptime ignores Timezone when parsing

When I run the following code strptime seems to ignore the timezone value. Just sets value of the local timezone (which is +10). This is the output, (Running on Linux, compiled with gcc 4.6.3): -----------2013-04-24T9:47:06+400 -…
pt123
  • 2,146
  • 1
  • 32
  • 57
3
votes
1 answer

R: strptime() and is.na () unexpected results

I have a data frame with roughly 8 million rows and 3 columns. I used strptime() in the following manner: df$date.time <- strptime(df$date.time, "%m/%d/%y %I:%M:%S %p") This works fine for all but 1104 of the rows, which I checked…
Jota
  • 17,281
  • 7
  • 63
  • 93
3
votes
3 answers

Parse hours without leading zeroes by strptime in Python

Suppose you have time in this format: a = [..., 800.0, 830.0, 900.0, 930.0, 1000.0, 1030.0, ...] The problem is that leading zeroes for hours are missing. For example 00:30 is represented by 30, 08:00 is represented by 800. and 00:00 is represented…
abudis
  • 2,841
  • 6
  • 32
  • 41
3
votes
6 answers

Converting date formats python - Unusual date formats - Extract %Y%M%D

I have a large data set with a variety of Date information in the following formats: DAYS since Jan 1, 1900 - ex: 41213 - I believe these are from Excel http://www.kirix.com/stratablog/jd-edwards-date-conversions-cyyddd YYDayofyear - ex…
ccdpowell
  • 629
  • 5
  • 14
  • 22
3
votes
1 answer

zoo/xts microsecond read issue

The data looks like Time Set1 Set2 10:19:38.551629 16234 16236 10:19:41.408010 16234 16236 10:19:47.264204 16234 16236 I am trying to load this into zoo. orig <-…
shoonya
  • 292
  • 1
  • 10
3
votes
2 answers

python strptime wrong format with 12-hour hour

My string format currently is datetime.strptime(date_as_string, '%d/%m/%y %I:%M %p') this unfortunately does not work with input such as 1/12/07 00:07 AM How I can get strptime to recogize this format ? EDIT: ValueError: time data '1/12/07 00:07…
Ponytech
  • 1,634
  • 14
  • 21
2
votes
1 answer

Why is strptime is 4 hours off?

How do I use strptime to format "%Y-%m-%dT%H:%M:%SZ" into the correct UNIX timestamp? I tried writing a method called testDateWithString (below). But, it fails with error message: '2011-12-27 08:35:46 +0000' should be equal to '2011-12-27 04:35:46…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
2
votes
0 answers

Implementing strftime and strptime for custom date class

I've written a custom date class for a non-Gregorian calendar system. Is there an easy way to implement strftime and strptime without having to implement all the logic myself? My class has a day, month and year field, so in principle all I would…
AlfaZulu
  • 921
  • 5
  • 13
2
votes
1 answer

Rust Polars: how to change column value from string to datetime

I'm reading my CSV file with polars, but there's a column with values that I need to convert to DateTime. I've managed to manipulate the String (remove dots) now I need to strptime to convert to DateTime. How can I do this in rust polars? My old…
Marcel
  • 23
  • 4
2
votes
0 answers

Converting text to datetime.datetime object? (Error: ValueError: time data '2022-04-18T10:00:00-07:00' does not match format '%y-%m-%dT%H:%M:%S%z')

I have a datetime.datetime object that gets stored as text in a text file. Later, I have to convert that text back to a datetime.datetime object. The object is in this format 2022-04-18T10:00:00-07:00 but I'm having trouble using the strp time…
2
votes
1 answer

Using python datetime.datetime.strptime on windows with BST timezone

I need to parse many different dates in many different formats. I am having trouble with the following and wondered if anyopne could explain why; The following works on a linux system: from datetime import datetime datetime.strptime('Tue 23 Aug 2011…
Matt Warren
  • 669
  • 8
  • 18