Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Django': 0.03; 'value,': 0.04; 'subject:Python': 0.06; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'bayl': 0.16; 'finney': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'skip:t 110': 0.16; 'modification': 0.16; '>>>': 0.22; '+0000': 0.22; 'header:User-Agent:1': 0.23; 'compare': 0.26; 'shown': 0.26; 'header:X-Complaints-To:1': 0.27; 'van': 0.27; 'gives': 0.31; 'writes:': 0.31; 'subject:time': 0.33; 'display': 0.35; 'but': 0.35; 'received:com.au': 0.36; 'ben': 0.38; 'to:addr :python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; "you're": 0.61; 'show': 0.63; 'received:125': 0.84; 'cryptography': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: modification time in Python - Django: datetime != datetime :-( Date: Tue, 04 Mar 2014 08:06:21 +1100 References: <20140303133541.66fccbbb@lia.custard.shrl.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: vmx15867.hosting24.com.au X-Public-Key-ID: 0xBD41714B X-Public-Key-Fingerprint: 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-gpg.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:WQOJ8a5VPDmFPDgClti5LSNOFmQ= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393880794 news.xs4all.nl 2962 [2001:888:2000:d::a6]:52039 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67579 Jaap van Wingerde 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@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 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