We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Format AM/PM abbreviations with periods (AP Style)

How Do I?

Jeremy's avatar
Jeremy
3 posts
5 years ago
Jeremy's avatar Jeremy

Looking to format am/pm abbreviations with periods “a.m.” and p.m.”. Is this possible without manually formatting this field in entries?

Time: {event_start_date format="%g:%i %a"} – {event_end_date format="%g:%i %a"}
       
Robin Sowell's avatar
Robin Sowell
13,160 posts
5 years ago
Robin Sowell's avatar Robin Sowell

I’d probably lean toward manually formatting it. But- a/A are among the date format variables that are processed through the language variables. In other words- you could make a separate language pack for it. The bit you’re interested in is in core_lang.php.

You could copy over that file, just keep the am/pm and edit it.

But that really seems overkill- I’d just format it manually.

       
Jeremy's avatar
Jeremy
3 posts
5 years ago
Jeremy's avatar Jeremy

A challenge with manual formatting is I would be unable to use the localized date field type. I would really prefer to have a way to format with the periods. Any other options beyond overwriting the core_lang.php file?

       
Robin Sowell's avatar
Robin Sowell
13,160 posts
5 years ago
Robin Sowell's avatar Robin Sowell

Well, you wouldn’t overwrite it, you’d make a new language pack with just the one file.

BUT- when I say manually, I meant:

{event_start_date format="%g:%i"} {if  '{event_start_date format="%a"}' == 'am'}a.m.{if:else}p.m.{/if}

Make sense?

? 1
       
Jeremy's avatar
Jeremy
3 posts
5 years ago
Jeremy's avatar Jeremy

Thanks, Robin this will work great!

? 1
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.