Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6541309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:05:22+00:00 2026-05-25T11:05:22+00:00

I have a timestamp with timezone information in string format and I would like

  • 0

I have a timestamp with timezone information in string format and I would like to convert this to display the correct date/time using my local timezone. So for eg… I have

timestamp1 = 2011-08-24 13:39:00 +0800

and I would like to convert this to say timezone offset +1000 to dsiplay

timestamp2 = 2011-08-24 15:39:00 +1000

I have tried using pytz but couldnt find many examples showing how to use the offset information. One other link that I found on stackoverflow which depicts this exact problem is here. I was hoping there was some better way I could handle this using pytz. Thanks for all suggestions in advance :).

UPDATE

Thanks Cixate. I just found the solution which is very similar to yours. Found these links helpful – LINK1 and LINK2

Posting the solution for everyones benefit

from datetime import datetime
import sys, os
import pytz
from dateutil.parser import parse

datestr = "2011-09-09 13:20:00 +0800"
dt = parse(datestr)
print dt
localtime = dt.astimezone (pytz.timezone('Australia/Melbourne'))
print localtime.strftime ("%Y-%m-%d %H:%M:%S")
2011-09-09 15:20:00
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:05:23+00:00Added an answer on May 25, 2026 at 11:05 am

    datetime.astimezone will do your basic conversion once you have a datetime object. If you’re trying to get a datetime object from a string, pip install python-dateutil and it’s as simple as:

    >>> from dateutil.parser import parse
    >>> from dateutil.tz import tzoffset
    >>> dt = parse('2011-08-24 13:39:00 +0800')
    datetime.datetime(2011, 8, 24, 13, 39, tzinfo=tzoffset(None, 28800))
    >>> dt.astimezone(tzoffset(None, 3600))
    datetime.datetime(2011, 8, 24, 6, 39, tzinfo=tzoffset(None, 3600))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a unix timestamp that I would like to convert using mysql if
I have timestamp in milliseconds from 1970. I would like to convert it to
Using MySQL, i have a current timestamp that looks like this: 2011-11-01 10:34:24 Is
I have a utc timestamp in the IS8601 format and am trying to convert
I have a Java Date object containing date and time information. I want to
I have asked aqbout timezones and date/time before but this is a more specific
So I've got a text input that get's date & time in this format:
i have written a code which converts date and time into timezone , now
All, How can I convert to a unix timestamp to date and time in
I have a custom UserType which stores a date/time value in a TIMESTAMP field

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.