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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:43:44+00:00 2026-05-26T06:43:44+00:00

Python 2.6: import pytz import time import datetime time.mktime(datetime.datetime(1990, 1, 1, tzinfo=pytz.utc).timetuple()) Result: 631148400.0

  • 0

Python 2.6:

import pytz
import time
import datetime
time.mktime(datetime.datetime(1990, 1, 1, tzinfo=pytz.utc).timetuple())

Result:

631148400.0

Boost 1.46:

auto a = boost::posix_time::ptime(boost::gregorian::date(1990, 1, 1));
auto b = boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1)); // unix epoch
boost::posix_time::time_duration x = a - b;
std::cerr << x.total_seconds() << std::endl;

Result:

631152000

Difference is 3600 (1 hour). Why?

  • 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-26T06:43:44+00:00Added an answer on May 26, 2026 at 6:43 am

    For the example below I set my time zone to GMT-01:

    >>> import datetime, time, pytz
    
    >>> tz = pytz.FixedOffset(-60)
    >>> dt = datetime.datetime(1990, 1, 1, tzinfo=pytz.utc)
    
    >>> tm = dt.astimezone(tz).timetuple(); tm
    time.struct_time(tm_year=1989, tm_mon=12, tm_mday=31, tm_hour=23, tm_min=0, tm_s
    ec=0, tm_wday=6, tm_yday=365, tm_isdst=0)
    
    >>> time.mktime(tm)
    631152000.0
    

    mktime takes a time tuple based on local time, so the UTC datetime object has to first be adjusted to local time.

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

Sidebar

Related Questions

I'm writing a simple alarm utility in Python. #!/usr/bin/python import time import subprocess import
So I have datetime objects in UTC time and I want to convert them
#!/usr/bin/env python import os, sys, subprocess, time while True: print subprocess.call(xsel, shell=True); time.sleep(1); Takes
The Boost documentation does not specify this. When I use boost::python::import , where exactly
My code: #!/bin/python import os,sys from datetime import datetime from flask import Flask from
I implemented a simple state machine in Python: import time def a(): print a()
I have a simple example: #!/usr/bin/python import time import fcntl file = open(e, w)
Firstly, here's my script: #!/usr/bin/python import sys, os sys.path.append('/home/username/python') sys.path.append(/home/username/python/flup) sys.path.append(/home/username/python/django) # more path
I'm attempting a pretty cut & dry example of anydbm: #!/usr/bin/python import anydbm #
The python implementation import sys def move(src, dst, tmp, num): if num == 1:

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.