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

Ben Finney ben+python at benfinney.id.au
Mon Mar 3 22:06:21 CET 2014


Jaap van Wingerde <mailinglists at vanwingerde.nl> writes:

> >>> 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'
> >>> 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 gives the right modification time. What is wrong?

You're using ‘gmtime’ to display the Python datetime value, but ‘ls’
will display the time in the local timezone. Do you have a strange
timezone set?

What value does the Python datetime value show in the local timezone?
How does that compare to the time shown by ‘ls’?

-- 
 \              “When cryptography is outlawed, bayl bhgynjf jvyy unir |
  `\                                              cevinpl.” —Anonymous |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list