Search code examples
python-3.4python-dateutil

Python- Parser the today's date out of Dateutil


I am working with Dateutil module in Python 3.4.1, and I'm trying to extract only the date part out of the code. For example

from datetime import *
date.today()

Results in:

datetime.date(2014, 8, 2)

Is there a way to remove the front part and use the remaining numbers as a text or string? I'm trying to use this in conjunction with Tkinter's entry widgets, any help would be appreciated.


Solution

  • from datetime import *
    today = date.today()
    print(today.strftime('%Y-%m-%d'))
    

    will result in

    '2014-08-03'
    

    Have a look at http://strftime.net/ for formatting help.