"P Difference to Greenwich time (GMT) with colon between hours and
minutes Example: +02:00"
However in django, P() appears to be implemented as
"Time, in 12-hour hours, minutes and 'a.m.'/'p.m.', with minutes left off
if they're zero and the strings 'midnight' and 'noon' if
appropriate.
Examples: '1 a.m.', '1:30 p.m.', 'midnight', 'noon', '12:30 p.m.'
Proprietary extension."
For example:
{{{
DateFormat(self.created_on).format("F jS Y, h:ia P")
}}}
returns "March 5th 2023, 08:44a.m. 8:44 a.m." when it should return "March
5th 2023, 08:44a.m. -05:00"
--
Ticket URL: <https://code.djangoproject.com/ticket/34387>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => wontfix
Comment:
Thanks for this patch, however it works as
[https://docs.djangoproject.com/en/stable/ref/templates/builtins/#date
documented]:
> ''"Uses a similar format to PHP’s date() function** with some
differences**."''
> ''"Time, in 12-hour hours, minutes and ‘a.m.’/’p.m.’, with minutes left
off if they’re zero and the special-case strings ‘midnight’ and ‘noon’ if
appropriate. Proprietary extension."''
We will not make a backward incompatible change to follow the PHP
implementation.
--
Ticket URL: <https://code.djangoproject.com/ticket/34387#comment:1>
* status: closed => new
* type: Bug => Uncategorized
* version: 3.2 => 4.2
* resolution: wontfix =>
Comment:
In that case the inline documentation is incorrect and should be updated
as in djang.utils.dateformat it still, as of 4.2, reads:
{{{
"""
PHP date() style date formatting
See http://www.php.net/date for format strings
Usage:
>>> import datetime
>>> d = datetime.datetime.now()
>>> df = DateFormat(d)
>>> print(df.format('jS F Y H:i'))
7th October 2003 11:39
>>>
"""
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34387#comment:2>
* owner: nobody => ayushbisht2001
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/34387#comment:3>
* status: assigned => closed
* resolution: => wontfix
Comment:
I appreciate you'd like to reopen the ticket, but I don't see anything
wrong in this docstring. We could remove ''"See http://www.php.net/date
for format strings"'' as there is no need to check PHP docs for format
strings but such a tiny cleanup doesn't require a ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/34387#comment:4>