pythondatetimezope

Where has now() moved in DateTime 2.12


I have a product which I'm supporting which uses the now() method from the DateTime module.

from DateTime import now

However, in DateTime 2.12 this method no longer exists.

Has it been moved to a new location, or is there a new/preferred idiom for getting the current time?


Solution

  • From this page:

    If the function is called with no arguments, then the current date/ time is returned, represented in the timezone of the local machine.

    I browsed through the code of DateTime.py and I didn't see a now() method. So to answer your question, to get the current time just do a current = DateTime().