Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'python.': 0.02; 'applicable,': 0.07; 'error:': 0.07; 'formatting': 0.09; 'happen,': 0.09; 'lawrence': 0.09; 'python': 0.11; 'language.': 0.14; 'question.': 0.14; 'igor': 0.16; 'mark,': 0.16; 'seconds,': 0.16; 'skip:q 50': 0.16; 'timestamp': 0.16; 'language': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'trying': 0.19; 'properly': 0.19; 'value.': 0.19; 'import': 0.22; 'to:name:python-list@python.org': 0.22; 'error': 0.23; '\xa0if': 0.24; '---': 0.24; 'question': 0.24; 'this:': 0.26; 'asking': 0.27; 'header:In-Reply-To:1': 0.27; 'record': 0.27; 'point': 0.28; 'function': 0.29; 'leave': 0.29; 'related': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'gives': 0.31; 'code': 0.31; 'getting': 0.31; 'object.': 0.31; 'produces': 0.31; 'url:python': 0.33; 'convert': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'google': 0.35; 'there': 0.35; 'dates': 0.36; 'described': 0.36; 'url:listinfo': 0.36; "i'll": 0.36; 'possible': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'should': 0.36; 'too': 0.37; 'expected': 0.38; 'thank': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'does': 0.39; 'environment.': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'how': 0.40; 'read': 0.60; 'easy': 0.60; 'free': 0.61; 'viruses': 0.61; 'range': 0.61; 'first': 0.61; 'you.': 0.62; 'protection': 0.63; 'our': 0.64; 'provide': 0.64; 'different': 0.65; 'mar': 0.68; 'antivirus': 0.68; 'cut': 0.74; 'milliseconds': 0.84; 'stamp': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=6bf4UkmDcIWJAsrc45yNWzVVhbxtK5PvNgjxji0kvEY=; b=VTregKbPDKT+F8AtizbpFXeEBlBGlU8uyLeZPrcD2JzCUfVsFdP1AVvlUdx4ucVFQt DPQy8VFSc/MoJTTHo82X0EtVCkRcw3gIevk2QPdoKzYSE33deoH4xAjzMteyk6nHWzNs 9UkO2tTXw1+8GNpPl8S+2lgYTnlE1nGruW7NKXqDSjtAFrjtbueRUZgeot0frBKUGHh1 Fi7vdQHpYtN/ChB0UXRAuOGrx5ZWYMO1fUNnr5TZ392j/mhxBKc2kHgeMKeZw6SLZf4K LiKs0MlP3aN2zCHS3eCJxQTwclSX1TjxTc1HLG4eZrBmPvaEkAXC2fI/dlfGWBHdK6fG zMEg== MIME-Version: 1.0 X-Received: by 10.58.128.72 with SMTP id nm8mr1585853veb.18.1393970111924; Tue, 04 Mar 2014 13:55:11 -0800 (PST) In-Reply-To: References: Date: Tue, 4 Mar 2014 13:55:11 -0800 Subject: Re: Proper conversion of timestamp From: Igor Korot To: "python-list@python.org" Content-Type: multipart/alternative; boundary=047d7b675cd259513f04f3cef5c6 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 165 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393970120 news.xs4all.nl 2844 [2001:888:2000:d::a6]:53773 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67733 --047d7b675cd259513f04f3cef5c6 Content-Type: text/plain; charset=ISO-8859-1 Hi, Mark, On Tue, Mar 4, 2014 at 1:44 PM, Mark Lawrence wrote: > On 04/03/2014 20:57, Igor Korot wrote: > >> Hi, ALL, >> I'm getting this: >> >> timestamp out of range for platform localtime()/gmtime() function >> >> trying to convert the timestamp with milliseconds into the datetime >> object. >> >> The first hit of Google gives me this: >> >> http://stackoverflow.com/questions/12458595/convert- >> epoch-timestamp-in-python >> >> but the solution described is not good for me since it does not gives >> me the milliseconds value. >> >> How do I get the proper datetime value including milliseconds from the >> timestamp? >> >> Thank you. >> >> > You have a long record of asking timestamp related questions so you should > know where the docs are that provide the answer to this question. I'll > leave you to go off and read them. If you don't understand them, please > cut and paste your code here, state what you expected to happen, what > actually happened, including any traceback if applicable, and then we'll be > happy to point you the error of your ways. > Working with the dates is not that easy and not just in Python. There are too many different formatting involved with many different representation. And on top of it it is possible to use one system in completely different environment. But this particular question is easy. What I have is a timestamp which reads: 1289410678L. Trying to convert this into the datetime object in Python using: import datetime datetime.datetime.fromtimestamp( stamp ) produces the error: timestamp out of range for platform localtime()/gmtime() function. This is because this timestamp is not in seconds, but rather in milliseconds. Now the question I have is: how do I properly convert this timestamp into the datetime object with the milliseconds? Thank you. > > -- > My fellow Pythonistas, ask not what our language can do for you, ask what > you can do for our language. > > Mark Lawrence > > --- > This email is free from viruses and malware because avast! Antivirus > protection is active. > http://www.avast.com > > > -- > https://mail.python.org/mailman/listinfo/python-list > --047d7b675cd259513f04f3cef5c6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi, Mark,

On Tue, Mar 4, 2014 at 1:44 PM, Mark Lawrence <= span dir=3D"ltr"><breamoreboy@yahoo.co.uk> wrote:
On 0= 4/03/2014 20:57, Igor Korot wrote:
Hi, ALL,
I'm getting this:

timestamp out of range for platform localtime()/gmtime() function

trying to convert the timestamp with milliseconds into the datetime object.=

The first hit of Google gives me this:

http://stackoverflow.com/questions/= 12458595/convert-epoch-timestamp-in-python

but the solution described is not good for me since it does not gives
me the milliseconds value.

How do I get the proper datetime value including milliseconds from the
timestamp?

Thank you.


You have a long record of asking timestamp related questions so you should = know where the docs are that provide the answer to this question. =A0I'= ll leave you to go off and read them. =A0If you don't understand them, = please cut and paste your code here, state what you expected to happen, wha= t actually happened, including any traceback if applicable, and then we'= ;ll be happy to point you the error of your ways.

Working with the dates is no= t that easy and not just in Python.
There are too many differ= ent formatting involved with many different representation.
And on top of it it is possible to use one system in completely different e= nvironment.

But this particular question is easy.

=
What I have is a timestamp which reads: 1289410678L.

Trying to convert this into the datetime object in Python using:=

import datetime
datetime.datetime.fromtime= stamp( stamp )

produces the error: timestamp out of range= for platform localtime()/gmtime() function.

This is because this timestamp is not in seconds, but rather= in milliseconds.

Now the question I have is: how do I pr= operly convert this timestamp into the datetime object with the millisecond= s?

Thank you.
=A0

--
My fellow Pythonistas, ask not what our language can do for you, ask what y= ou can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protec= tion is active.
http://www.avast.com=


--
https://mail.python.org/mailman/listinfo/python-list

--047d7b675cd259513f04f3cef5c6--