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

  • Home
  • SEARCH
  • 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 8588945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:55:34+00:00 2026-06-11T22:55:34+00:00

I have a javascript calendar that is sending me a unixtimestamp. I am in

  • 0

I have a javascript calendar that is sending me a unixtimestamp. I am in Singapore. I want this timestamp to be interpreted as a Singapore timestamp and then converted to utc for comparisons with the db.

I cant, for the life of myself, figure out how to tell django that this time stamp is from the current timezone, Singapore.

When i do a print statement of the timestamp, it adds 8 hours to the time (which means that django thinks I input the time in utc and is localizing it to the Singaporean context)

Among many other things, I tried:
start=datetime.datetime.fromtimestamp(int(start_date)).replace(tzinfo=get_current_timezone())

The start_date is 1325376000 (which translates to 2012-01-01 00:00:00)

However,when i print the output of this I get 2012-01-01 08:00:00+06:55. I dont even know where +06:55 is coming from when singapore is +08:00. I am SO lost.

Thanks for your help.

settings.py:

TIME_ZONE = 'Asia/Singapore'

USE_TZ = True

  • 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-11T22:55:35+00:00Added an answer on June 11, 2026 at 10:55 pm

    Assuming you’ve got pytz installed:

    from datetime import datetime
    import pytz
    local_tz = pytz.timezone("Asia/Singapore") 
    utc_dt = datetime.utcfromtimestamp(timestamp).replace(tzinfo=pytz.utc)
    local_dt = local_tz.normalize(utc_dt.astimezone(local_tz))
    

    For example:

    >>> from datetime import datetime
    >>> import pytz
    >>> local_tz = pytz.timezone("Asia/Singapore")
    >>> utc_dt = datetime.utcfromtimestamp(1325376000).replace(tzinfo=pytz.utc)
    >>> utc_dt
    datetime.datetime(2012, 1, 1, 0, 0, tzinfo=<UTC>)
    >>> local_dt = local_tz.normalize(utc_dt.astimezone(local_tz))
    >>> local_dt
    datetime.datetime(2012, 1, 1, 8, 0, tzinfo=<DstTzInfo 'Asia/Singapore' SGT+8:00:00 STD>)
    >>> local_dt.replace(tzinfo=None)
    datetime.datetime(2012, 1, 1, 8, 0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a button that I want to open a calendar and then disappear
I have a web application that has a dynamic javascript calendar, which allows users
I'm pulling my hair out over this. I have this bit of javascript that
I have a javascript plugin in my rails project that loads an image this
I have made this script that get's the month and the year from calendar.php
I have existing javascript in a project that creates a 'Calendar' object. The object
I have created a drop down that works as a calendar in javascript. I
I have a textbox.In its onclick iam calling a javascript fn to call calendar.Texbox
I have javascript code some thing like this -- var count=3; var pl=new Array(count);
I have Javascript function defined in the main index.html file. One part of this

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.