Reputation: 338
I have an application in Symfony where when a user posts a comment, the comment's creation time is stored. Then, it is converted to the correct format with twig, like so:
{{ comment.created|date('m-d-Y H:i:s a') }}
The only problem is, if the user submitted the comment at 4 P.M., it comes up as 16 P.M.
I'd like it to just show 4 P.M.
Thanks in advance for all the help!
Upvotes: 3
Views: 10699
Reputation: 2631
Use h
instead of H
{{ comment.created|date('m-d-Y h:i:s a') }}
From: https://php.net/manual/en/function.date.php
h 12-hour format of an hour with leading zeros
H 24-hour format of an hour with leading zeros
Upvotes: 14