Re: strftime silliness
| From: | Geoff Shang | Date: | Wed, 11 Apr 2012 00:47:14 +0000 |
| Subject: | Re: strftime silliness | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-317516@lists.php.net to get a copy of this message | ||
On Wed, 10 Apr 2012, Tim Streater wrote:
I want to format a date/time using a 12 hour representation of the time part. I can do this with, say, "%d %b %Y %l:%M %p", where the first time format specifier is the lower-case L. But, this gives me a leading space in the case that the hour is less than 12. I don't want this space. Anyone know of an simple way to avoid it? There appears to be no specifier to do this. Of course, I can call strftime twice, once for the date portion and once for the time portion, trimming the latter, but that seems clumsy.You can use %-l to achieve this. You could also use %-I as this will also drop leading zeros if present. I forget where I read about this. I'm almost certain that it was *not* in any PHP documentation. HTH, Geoff.