Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #32478

Re: date and time comparison how to

Date 2012-10-30 05:35 -0400
From Dave Angel <d@davea.name>
Subject Re: date and time comparison how to
References (3 earlier) <6101355b-ae00-4482-96ee-ed60f5cb465f@googlegroups.com> <85ea1841-6849-4970-b08b-5c7bbb7bba14@googlegroups.com> <6f437b0f-1fe5-49c6-98e3-7be615d04858@googlegroups.com> <mailman.3068.1351566714.27098.python-list@python.org> <d6043deb-74d8-4c3a-9661-228ab7f17291@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.3084.1351589734.27098.python-list@python.org> (permalink)

Show all headers | View raw


On 10/30/2012 12:20 AM, noydb wrote:
> On Monday, October 29, 2012 11:11:55 PM UTC-4, Dave Angel wrote:
>> On 10/29/2012 10:13 PM, noydb wrote:
>>
>>> I guess I get there eventually!  
>>
>>> <snip>
>>
>>
> 
> okay, I see.
> But for the user supplied date... I'm not sure of the format just yet... testing with a string for now (actual date-date might be possible, tbd later), so like '10292012213000' (oct 29, 2012 9:30pm).  How would you get that input into a format to compare with dt above?
> 

See http://docs.python.org/2/library/datetime.html

There are a number of constructors for datetime.  For example,

now = datetime.datetime.now()

spec = datetime.strptime(datstring, format)

spec = datetime.datetime(year, month, day[, hour[, minute[, second[,
microsecond)

In each case, you have an optional tz for timezone.  Or if possible, use
utc versions of these functions to get "greenwich" times.  tz is one of
the biggest pains, and the quirks vary between operating systems and
filesystems.  If possible in your environment, use   utcnow,
utcfromtimestamp, etc.


-- 

DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 16:13 -0700
  Re: date and time comparison how to Gary Herron <gherron@digipen.edu> - 2012-10-29 17:04 -0700
  Re: date and time comparison how to MRAB <python@mrabarnett.plus.com> - 2012-10-30 00:50 +0000
    Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 18:47 -0700
      Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 19:02 -0700
        Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 19:13 -0700
          Re: date and time comparison how to Dave Angel <d@davea.name> - 2012-10-29 23:11 -0400
            Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 21:20 -0700
              Re: date and time comparison how to Chris Angelico <rosuav@gmail.com> - 2012-10-30 17:12 +1100
              Re: date and time comparison how to Dave Angel <d@davea.name> - 2012-10-30 05:35 -0400
            Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 21:20 -0700
          Re: date and time comparison how to MRAB <python@mrabarnett.plus.com> - 2012-10-30 03:30 +0000
        Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 19:13 -0700
      Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 19:02 -0700
    Re: date and time comparison how to noydb <jenn.duerr@gmail.com> - 2012-10-29 18:47 -0700
  RE: date and time comparison how to "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-10-31 21:04 +0000
  Re: date and time comparison how to Adam  Tauno Williams <awilliam@whitemice.org> - 2012-11-02 07:22 -0400

csiph-web