Set Date and Time on Python
Dave Angel
d at davea.name
Thu Apr 26 07:00:39 EDT 2012
On 04/26/2012 03:09 AM, viral shah wrote:
> Hi
>
> I'm very new to Python programming.
>
> Please help me to add date and time !
>
> Following is the code done by me.
>
> import datetime
> class Module
> type(datetime.datetime)
>
> Now what's the next to do for displaying date and time ?
>
Your subject line says you want to SET date and time. But the body of
your message says you want to display it.
See http://docs.python.org/library/datetime.html, which I got to by
searching the docs for datetime.
For date, try
import datetime
today = datetime..date.today()
datestr = today.isoformat()
print datestr
now =datetime.datetime.today()
datetimestr = now.isoformat()
print datetimestr
#2012-04-26T06:56:44.849589
For more flexibility, look up datetime.strftime()
--
DaveA
More information about the Python-list
mailing list