Set Date and Time on Python

Shambhu Rajak Shambhu.Rajak at kpitcummins.com
Fri Apr 27 02:41:01 EDT 2012



-----Original Message-----
From: Dave Angel [mailto:d at davea.name] 
Sent: 26/04/2012 4:31 PM
To: viral shah
Cc: python-list at python.org
Subject: Re: Set Date and Time on Python

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 ?
>

Try this:
import datetime

now = datetime.datetime.now()
now.strftime("%Y-%m-%d-%H:%M")----this will give you date time in this format " 2012-04-27-12:08"

Hope this will work for you!!! 
Cheerz

Shambhu





More information about the Python-list mailing list