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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:46:14+00:00 2026-06-04T00:46:14+00:00

I have some code for converting some timestamps stored as strings into datetime objects

  • 0

I have some code for converting some timestamps stored as strings into datetime objects and noticed today exceptions when it converts dates with an int timestamp value greater than the max int.

datetime.datetime.fromtimestamp(2147570047)

for example gives me

ValueError: timestamp out of range for platform time_t

How can I get around this problem? assuming that I want to stay on 32-bit python (running 2.7.2)

I noticed I can convert the max int into the datetime object then add on any extra with timedeltas but I couldn’t think of a particularly efficient or nice way of doing this in practice. What’s a good way I can convert these 2038+ timestamps into datetime objects?

  • 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-04T00:46:16+00:00Added an answer on June 4, 2026 at 12:46 am

    Think i worked it out, and I was kinda surprised that this doesn’t throw the same exception

    >>> datetime.datetime.fromtimestamp(0) + datetime.timedelta(seconds=2147570047)
    datetime.datetime(2038, 1, 20, 4, 14, 7)
    

    EDIT: This isn’t a perfect solution, seems to be a bit of issues with time zones (I’m currently on BST time (+1) so might explain why this below is an hour apart)

    >>> datetime.datetime.fromtimestamp(2047570047)
    datetime.datetime(2034, 11, 19, 17, 27, 27)
    >>> datetime.datetime.fromtimestamp(0) + datetime.timedelta(seconds=2047570047)
    datetime.datetime(2034, 11, 19, 18, 27, 27)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am converting some code from Perl into .NET. I have this s/// pattern
I have some classic asp code that needs converting to asp.net. So far I
I have some source code that was compiled on Windows. I am converting it
I am converting some Fortran90 code to C#. I have some knowledge of Fortran77
I am having trouble converting some code from VB6 to VB.NET (I don't have
I have been converting some code from C++ to C#. My lack of understanding
I am tasked with converting some Python code to Java. I have some experience
I'm converting Visual Basic.Net code to C# in my project. But I have some
I'm converting some JavaScript code to jQuery and have come to a halt, Heres
I'm just beginning in scala and I'm converting some java code into scala and

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.