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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:32:05+00:00 2026-06-09T18:32:05+00:00

I have a web app that captures date / time via a JS script

  • 0

I have a web app that captures date / time via a JS script and calculates seconds since epoch in UTC format – ex 134250270000. In the backend we have a Python script that fetches data from DB but has date / time stored in number of seconds since epoch in PST format. There is always a difference of seconds between UTC and PST if counted from epoch.

Is there any method by which I can convert the UTC seconds since to epoch to PST seconds since epoch? We need to take a note of daylight changes in PST timezone also?

EDIT::

I have the seconds since epoch in UTC format:

1342502700

I found that I get the sum in seconds between UTC and local standard time via:

>>> time.timezone / 3600
8

So If I add 1342502700 to time.timezone:

>>> print 1342502700 + time.timezone
1344153600

Will it always give me PDT / PST times correctly?

EDIT::

Maybe this is the correct one:

>>> import time
>>> offset = time.timezone if (time.daylight == 0) else time.altzone
>>> offset / 60 / 60
7

time.daylight will be non-zero if daylight savings is currently in effect.

  • 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-09T18:32:06+00:00Added an answer on June 9, 2026 at 6:32 pm

    I think somewhere in your conversions there’s an implied time zone that’s messing things up. Regardless, I think what you’re looking for is time.altzone:

    >>> from time import *
    >>> ctime(time())
    'Mon Aug 13 16:54:02 2012'
    >>> ctime(time()+altzone)
    'Mon Aug 13 08:54:04 2012'
    

    I’m on Taipei time right now, so my local time (the first one) is later than UTC.

    EDIT: I missed the line in the documentation that says only to use altzone if daylight is non-zero. Apparently it’s a bit more complicated than I thought if you live somewhere with Daylight Savings Time. Refer to this post if you need to deal with that:

    Python: get timezone based on DST for a timestamp

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

Sidebar

Related Questions

We have an web app that is talking to Netsuite via Netsuite's web services.
I have a web app that runs fine in Visual web developer. But when
I have a web app that reads data from a SQL DB that contains
I have a web app that has a big and complex form (fields, checks,
I have a web app that I've recently applied a jQuery ThemeRoller theme to.
I have a web app that lets a client define a daily rate for
We have a web app that we update and release almost daily. We use
I have a web app that uses the Active Directory Membership Provider and when
I have small web app that generate PDF files as a report. I'm trying
I have a web app that currently is inserting x (between 1 + 40)

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.