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

Jaap van Wingerde mailinglists at vanwingerde.nl
Mon Mar 3 09:28:21 EST 2014


Op <Tue, 4 Mar 2014 01:08:52 +1100> schreef Chris Angelico <rosuav at gmail.com> in bericht <CAPTjJmrp9Ca5zyfo75NKcX_ik0Qi4kOcjhhY6EEWKQ-xJx7KQg at 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 at 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 at 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 at liakoster:~$ 

ls is giving me the modified time.



More information about the Python-list mailing list