Returning Date As String ?

P

Peter Moscatt

I am wanting to return the system date using the following:

date.today()

How would I then convert this to a string ?

Pete
 
R

Roy Smith

Peter Moscatt said:
I am wanting to return the system date using the following:

date.today()

How would I then convert this to a string ?

Pete

datetime.data objects have a __str__() method. To convert one to a string,
you just have to cause its __str__() to be invoked. The most common ways
of doing that are str(), %s, or print:
'2005-05-14'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top