Sunday, June 22, 2014

Re: converting the format of datetime from datetime.datetime( yyyy mm dd hh mm tzinfo=) to yyyy mm dd hh mm

$ 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

https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior

http://strftime.org/

K



On Saturday, June 21, 2014 11:37:17 PM UTC-7, Rini Michael wrote:
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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2c1c6158-e47f-4c08-ad09-5e1df0df58bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment