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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:55:38+00:00 2026-05-28T02:55:38+00:00

I need to convert UTC time, (on ec2 instance) to PST. I am trying

  • 0

I need to convert UTC time, (on ec2 instance) to PST. I am trying to do this.

from datetime import datetime
from pytz import timezone
import pytz

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

my_timezone=timezone('US/Pacific')

date = my_timezone.localize(date)
date = date.astimezone(my_timezone)

print 'Local date & time is  :', date.strftime(date_format)

But the output is:

Current date & time is: 01/10/2012 20:01:14
Local date & time is  : 01/10/2012 20:01:14 PST

Any reason why I am not getting the right PST time?

  • 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-28T02:55:39+00:00Added an answer on May 28, 2026 at 2:55 am
    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)
    

    seems to work for me 🙂 – timezones are confusing, slowly making a plan of what I actually want to do helps me most of the time

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to convert an existing (datetime fields) db from local time ut UTC.
For example, I need to convert time from UTC to local. And I use
I need to parse a date/time string from user input, and convert to UTC
I need to convert DateTime+TimeZoneInfo into DateTimeOffset. How do I do this? I assume
I'm trying to convert a time info I reveive as a UTC string to
Using C#, I need to convert incoming datetime values into UTC. I know there
I am trying to convert boost::posix_time::ptime from GMT to UTC. I went on Boost
I need to have a common function to convert UTC time to EDT. I
I have a need to convert a utc system time to local time and
I have a String, representing time in UTC. I need to convert it to

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.