DateTime objectFormatting

Nikhil Verma varma.nikhil22 at gmail.com
Wed May 2 11:35:44 EDT 2012


Thanks

On Wed, May 2, 2012 at 8:27 PM, Chris Rebert <clp2 at rebertia.com> wrote:

> On Wed, May 2, 2012 at 7:49 AM, Nikhil Verma <varma.nikhil22 at gmail.com>
> wrote:
> <snip>
> >     def __unicode__(self):
> >         return "%s %s" % (self.name, self.date_created.strftime("%A %B
> %d"))
> >
> >
> > The user fills Gen GI in name and date along with time.
> >
> > What i am able to achieve with this class object to return is :-
> >
> > Gen GI Monday  May 7
> >
> > I want that the this class should return object like this :-
> >
> > Gen GI Monday AM, May 7
> > Pancreas Tuesday PM, May 8
> >
> > How can achieve AM and PM also ? with this datetime object
>
> Consult the docs.
> http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior:
> "%p     -- Locale’s equivalent of either AM or PM."
>
> So, strftime("%A %p, %B %d").
>
> Regards,
> Chris
>



-- 
Regards
Nikhil Verma
+91-958-273-3156
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120502/f2631274/attachment.html>


More information about the Python-list mailing list