converting the format of datetime from datetime.datetime( yyyy mm dd hh mm tzinfo=<UTC>) to yyyy mm dd hh mm

34 views
Skip to first unread message

Rini Michael

unread,
Jun 22, 2014, 2:37:17 AM6/22/14
to django...@googlegroups.com
Hi 
I am working in datetime in django,this is the code in my forms.py 

from_time = forms.DateTimeField(label="FromTime",
                                        required=True,
                                        input_formats=["%Y-%m-%d %H:%M:%S"],
                                        widget=DateTimeInput(format="%Y-%m-%d %H:%M:%S"))
all the values of fields are stored in a dictionary variable say dd,when i try to write the value of the dictionary in a file it is in the form

from_time   datetime.datetime(yyyy mm dd hh mm tzinfo=<UTC>)

can anyone suggest me how can i just get the value 2014 6 21 12 0 which is yyyy mm dd hh mm i need to take this value and set it as cron task

Thanks and regards 
Rini

Kelvin Wong

unread,
Jun 22, 2014, 11:58:29 PM6/22/14
to django...@googlegroups.com
$ python

Python 2.5.4 (r254:67917, Dec 23 2008, 14:57:27) 
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import datetime
>>> dt = datetime.datetime.utcnow()
>>> fmt = "%Y %m %d %H %M"
>>> print dt.strftime(fmt)
2014 06 23 03 54
>>> 

See also



K
Reply all
Reply to author
Forward
0 new messages