-1

Let's say I have an excel file named "hello123.xlsx". There is a column of timestamps that has a lot of rows (more than 50,000 rows). The image attached here is basically what the file looks like:

enter image description here

These timestamps are actually gathered from twitter streaming API. Now I need to convert them from GMT to San Francisco local time, which should be Pacific Time (PT) or specifically Pacific Daylight Time (PDT, UTC-7).

I searched some methods online but still failed to do so. I'm a beginner of python and I hope someone can help me figure it out. :)

liule123
  • 23
  • 1
  • 5

1 Answers1

1

Please take a look at this post: need to convert UTC (aws ec2) to PST in python

from datetime import datetime
from pytz import timezone
import pytz

date_format='%m/%d/%Y %H:%M:%S %Z'
date = datetime.now(tz=pytz.utc)
print 'Current date & time is:', date.strftime(date_format)

date = date.astimezone(timezone('US/Pacific'))

print 'Local date & time is  :', date.strftime(date_format)
spooky
  • 106
  • 1
  • 5
  • Hello Spooky, thank you for replying! But your code is for converting realtime time stamp. I am seeking converting a large excel lists of them. Please help! – liule123 May 01 '18 at 17:25