How to parse date/time string with timezone abbreviated name in Python?

0 votes

\\n votefavoriI'm trying to parse timestamp strings like "Sat, 11/01/09 8:00PM EST" in Python, but I'm having trouble finding a solution that will handle the abbreviated timezone.

I'm using dateutil's parse() function, but it doesn't parse the timezone. Is there an easy way to do this?

Nov 27, 2018 in Python by Anirudh
• 2,080 points
520 views

1 answer to this question.

0 votes
The parse() function in dateutil can't handle time zones. The thing I've been using is the %Z formatter and the time.strptime() function. I have no idea how it deals with the ambiguity in time zones, but it seems to tell the difference between CDT and CST, which is all I needed.

Background: I store backup images in directories whose names are timestamps using local time, since I don't have GMT clocks handy at home. So I use time.strptime(d, r"%Y-%m-%dT%H:%M:%S_%Z") to parse the directory names back into an actual time for age analysis.
answered Nov 27, 2018 by Nymeria
• 3,540 points

Related Questions In Python

0 votes
1 answer

How to convert string to date in python with different algorithms ?

Hello @ pagarsach, You can convert a string to ...READ MORE

answered 4 days ago in Python by Niroj
• 32,440 points
40 views
0 votes
1 answer

How to convert date string to date object in python?

Use this :-  >>> datetime.datetime.strptime('2405201 ...READ MORE

answered Oct 22, 2018 in Python by Priyaj
• 57,530 points
4,178 views
0 votes
1 answer

How to check if a string ends with a character in python?

You can use the endswith method. It checks ...READ MORE

answered Apr 4, 2019 in Python by Srisha
213 views
0 votes
1 answer

How to print a string with curly braces in Python?

You can use something like this - mystring ...READ MORE

answered Jul 23, 2019 in Python by Neel
• 3,010 points
1,439 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,050 views
0 votes
0 answers
+4 votes
6 answers
+1 vote
6 answers
0 votes
1 answer

How to calculate time interval between two time strings in Python

Try doing this - It is efficient for ...READ MORE

answered Nov 29, 2018 in Python by Nymeria
• 3,540 points

edited Dec 11, 2018 by Nymeria 673 views