Actually it is almost the same in Python .. :-)
import datetime year = datetime.date.today().year
Of course, the date has no time associated with this, so if you need it too, you can do the same with the full datetime object:
import datetime year = datetime.datetime.today().year
(Of course, there is nothing else, but you can store datetime.datetime.today () in a variable before capturing the year, of course).
It should be noted that the time components may differ between 32-bit and 64-bit pythons in some versions of python (I think this is a 2.5.x tree). Thus, you will find things like hour / min / sec on some 64-bit platforms, while you get hour / minute / second on 32-bit ones.
Nick Bastin Jul 15 '09 at 18:44 2009-07-15 18:44
source share