I want to get a file revision date from Python in UTC. The following code gives a date in my Linux Config Time Zone (GMT-5). I want it in UTC or how do I get the OS to replace the Time Zone with Patj? Python Python 2.6.5 (R255: 79063, 16 April 2010, 13:09:56) [GCC 4.4 .3] For more information on Linux 2, click "Help", " Copyright "," credit "or" license ". & Gt; & Gt; & Gt; That time import from datetime & gt; & Gt; & Gt; Import OS & gt; & Gt; & Gt; Dt = os.path.getmtime ('/ home / user / .bashrc') & gt; & Gt; & Gt; Datetime.datetime.fromtimestamp (dt) datetime (2012, 5, 30, 21, 18, 10)
thanks
Try
import datetime import os dt = os.path.getmtime ('/ home / me / .bashrc') Print ( Datetime datetime.fromtimestamp (dt)) print (datetime.datetime.utcfromtimestamp (dt))
Comments
Post a Comment