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 8014573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:58:38+00:00 2026-06-04T19:58:38+00:00

I want to convert the timestamp object(fetched from models) according to given UTC offset

  • 0

I want to convert the timestamp object(fetched from models) according to given UTC offset using Pytz. Before rendering it to the template when i prints timestamp object it does with the following format:

 2012-05-29 10:03:37

I am getting the offset with the following line:

 offset = datetime.datetime.now(pytz.timezone('Asia/Kolkata')).strftime('%z')

The above offset will give +0530
.Now i want to make the changes in timestamp object with this offset. For example :

timestamp: `2012-05-29 10:03:37`
offset:   `+0530`
after change,
timestamp: `2012-05-29 15:33:37`

What about this:

timestamp: `2012-05-29 23:03:37`
offset:   `+0530`
after change,
timestamp: `2012-05-30 4:33:37`

Look at the date it also changed according to offset. After manipulating the time it can be even in 12 hour format.

Any help will be appreciable

  • 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-06-04T19:58:40+00:00Added an answer on June 4, 2026 at 7:58 pm

    I hope this is what you’re looking for:

    d = datetime.now(pytz.timezone('UTC'))   # get date in UTC format - you'll be getting it from the database
    local = d.astimezone('Asia/Kolkata')
    print local.strftime("%Y-%m-%d %H:%M:%S %z")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I convert this timestamp from php into a javascript Date() object? This
I want convert GMT time to EST time and get a timestamp. I tried
I have a timestamp I want to convert to a date. I tried this
Using PHP, I want to convert UNIX timestamps to date strings similar to this:
I want to convert my CSS stylesheet units of measurement from Absolute to Relative.
I want to convert date time object in java to json string in format
So I have datetime objects in UTC time and I want to convert them
I want to convert string Date into Timestamp in java. The following coding i
is there a way to convert from unix timestamp to GMT in mysql while
I want to convert a data string into a timestamp (which would include the

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.