timedelta problem
Ian Kelly
ian.g.kelly at gmail.com
Thu Aug 14 23:44:54 EDT 2014
On Thu, Aug 14, 2014 at 9:37 PM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Thu, Aug 14, 2014 at 8:24 PM, luofeiyu <elearn2014 at gmail.com> wrote:
> > t1 is GMT time 2014 00:36:46
> > t2 is GMT time 2014 14:36:46
>
> You have it backwards. t1 is a later time than t2.
>
> > datetime.datetime.strptime do not give me the right answer.
>
> >>> dt1 - dt2
> datetime.timedelta(0, 50400)
> >>> _.seconds // 3600
> 14
>
> Looks correct to me.
Also:
>>> dt1.astimezone(datetime.timezone.utc)
datetime.datetime(2014, 8, 9, 14, 36, 46, tzinfo=datetime.timezone.utc)
>>> dt2.astimezone(datetime.timezone.utc)
datetime.datetime(2014, 8, 9, 0, 36, 46, tzinfo=datetime.timezone.utc)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140814/fef0d288/attachment.html>
More information about the Python-list
mailing list