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


Groups > comp.lang.python > #67577

Re: modification time in Python - Django: datetime != datetime :-(

Newsgroups comp.lang.python
Date 2014-03-03 12:22 -0800
References <20140303133541.66fccbbb@lia.custard.shrl.nl> <CAPTjJmrp9Ca5zyfo75NKcX_ik0Qi4kOcjhhY6EEWKQ-xJx7KQg@mail.gmail.com> <mailman.7646.1393856904.18130.python-list@python.org>
Message-ID <04659633-e14e-4d5b-90f2-93af04f056be@googlegroups.com> (permalink)
Subject Re: modification time in Python - Django: datetime != datetime :-(
From donarb <donarb@nwlink.com>

Show all headers | View raw


On Monday, March 3, 2014 6:28:21 AM UTC-8, Jaap van Wingerde wrote:
> Op <Tue, 4 Mar 2014 01:08:52 +1100> schreef Chris Angelico <rosuav@gmail.com> in bericht <CAPTjJmrp9Ca5zyfo75NKcX_ik0Qi4kOcjhhY6EEWKQ-xJx7KQg@mail.gmail.com>:
> 
> > See if ls is actually giving you ctime rather than mtime - compare the
> > results if you ask for os.path.getctime.
> 
> jaap@liakoster:~$ python
> Python 2.7.3 (default, Jan  2 2013, 13:56:14) 
> [GCC 4.7.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import os, time
> >>> from time import gmtime
> >>> time.strftime('%Y-%m-%dT%H:%m:%SZ',gmtime(os.path.getmtime('/var/django/test2/art/templates/art_index.html')))
> '2014-03-02T19:03:55Z'
> >>> time.strftime('%Y-%m-%dT%H:%m:%SZ',gmtime(os.path.getctime('/var/django/test2/art/templates/art_index.html')))
> '2014-03-02T19:03:55Z'
> >>> quit()
> jaap@liakoster:~$ ls --full-time /var/django/test2/art/templates/art_index.html
> -rwxrwx--- 1 lia www-data 2456 2014-03-02 19:16:55.568139590 +0000 /var/django/test2/art/templates/art_index.html
> jaap@liakoster:~$ 
> 
> ls is giving me the modified time.

You're using the months format '%m' when you should be using minutes '%M'.

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


Thread

Re: modification time in Python - Django: datetime != datetime :-( Jaap van Wingerde <mailinglists@vanwingerde.nl> - 2014-03-03 14:28 +0000
  Re: modification time in Python - Django: datetime != datetime :-( donarb <donarb@nwlink.com> - 2014-03-03 12:22 -0800
    Re: modification time in Python - Django: datetime != datetime :-( Chris Angelico <rosuav@gmail.com> - 2014-03-04 08:11 +1100
    Re: modification time in Python - Django: datetime != datetime :-( Jaap van Wingerde <mailinglists@vanwingerde.nl> - 2014-03-04 10:33 +0000
      Re: modification time in Python - Django: datetime != datetime :-( donarb <donarb@nwlink.com> - 2014-03-04 08:45 -0800
        Re: modification time in Python - Django: datetime != datetime :-( Roy Smith <roy@panix.com> - 2014-03-04 12:43 -0500

csiph-web