Reading a DWORD Date From Registry Using Python & _winreg
-
07-07-2021 - |
سؤال
I'm trying to read a DWORD date from the Windows registry using Python's _winreg.QueryValueEx
and I can't get the correct format.
DWORD Value: 5116e300
Output using _winreg.QueryValueEx: 1360454400
Desired Output: 2/10/2013
Can I use datetime
somehow?
Thank you
Edit
kindall's solution worked below.
The final line used was the following:
import time
t = 1360454400
print time.strftime("%m/%d/%y", time.gmtime(t))
المحلول
This will get you pretty close:
import time
t = 1360454400
print time.strftime("%m/%d/%y", time.gmtime(t))
To get it without the leading zeroes:
t = time.gmtime(t)
print "%d/%d/%2d" % (t.tm_mon, t.tm_mday, t.tm_year % 100)
نصائح أخرى
Strange that DWORD value of 5116e300
is actually a value of 1360388864
and not 1360454400
, but anyway...
ts = datetime.fromtimestamp(1360454400)
print '{:%m/%d/%Y}'.format(ts) #
# '02/10/2013'
or:
print '{0.month}/{0.day}/{0.year}'.format(ts)
# '2/10/2013'
لا تنتمي إلى StackOverflow