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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:32:08+00:00 2026-05-25T21:32:08+00:00

On my system, I have set the current time zone for my clock to

  • 0

On my system, I have set the current time zone for my clock to “Kuala Lumpur, Singapore (UTC+08:00)”, which puts my clock forward by eight hours (of course).

In python, I’m using the code to get the current time/date:

from datetime import datetime
dateTimeTuple = datetime.now()

I’m using this method as I need the individual parts (including the micro-second).

However, it will always returns me a regular time (not eight hours in front based on the selected time zone).

Is there another method?

  • 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-25T21:32:08+00:00Added an answer on May 25, 2026 at 9:32 pm

    datetime.now() returns a naive local datetime. To convert that to Kuala Lumpur time, you first need to make it a timezone-aware datetime, and then convert it to the Kuala Lumpur timezone:

    The easiest way to do timezone conversions is to use pytz.

    import pytz
    import datetime as dt
    kuala_lumpur=pytz.timezone('Asia/Kuala_Lumpur')
    localtz=pytz.timezone('Europe/London')
    

    Here is the naive datetime.

    now = dt.datetime.now()
    

    Use localize to make the datetime timezone aware.

    now=localtz.localize(now)
    print(now)
    # 2011-09-19 11:58:46.342254+01:00
    

    Use astimezone to convert to another timezone:

    now_in_kuala_lumpur=now.astimezone(kuala_lumpur)
    print(now_in_kuala_lumpur)
    # 2011-09-19 18:58:46.342254+08:00
    

    Due to Daylight Savings Time in the UK and no DST in Kuala Lumpur, the time difference is currently 7 hours.

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

Sidebar

Related Questions

I have a system in place which applies calculations to a set of numbers
I have been asked to set the system time of a Windows Mobile 6.0
We have set up a system where notifications get sent to a user with
I have set up a version control system using TortoiseSVN at my home to
I have a system set up to lock certain content in a database table
I have a set of Visual Studio Team System unit (integration really) tests that
I have a set of Berkeley DB files on my Linux file system that
I have a credit system set up on my site where user A can
I have a user system set up in a 'users' table, and I have
I have a potential client that set up their website and membership system in

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.