Jump to content

UK Date inconsistent formatting


christopher-w

Recommended Posts

Posted

IPS 4.3, Digital Ocean standalone, London.

Hey,

I have created a custom date field in the Pages app but the custom field is rendered in both US and UK formats, depending on where it's viewed. 

For example, when editing the date (Original Publication Date) in the article it expects a UK date, which is what I want.

image.png.1ac535a6dbf538b7edc0e50abc991f67.png

image.png.32235ff749195407e183dee54ec707c3.png

But when viewed, shown here at the top of the article, it renders in US date format:

image.png.900df185132b0e5fd81023809479f7d5.png

It also renders in US date format in the listing view.

 

However all other dates appear to render correctly, the issue appears to be restricted to custom date fields.

Just to be clear, I am in London and expect the entire site to show UK formatted dates. Or US formatted when viewed in the US. And so on.

Have I missed a config setting somewhere?

Many thanks

Chris

 

Posted

Found that I can create custom output in field display section - now just need to find out how to format a date using template language. 

 

image.thumb.png.ec0b21b2e8051c46519986b9ebe21b4c.png

40 minutes ago, AndyF said:

Do you have Calendar installed ? If so do the dates format correctly for you (dd/mm/yy) in that compared to (mm/dd/yy) ?

 Thanks, see above:

Posted

Oh OK. :) I had a vague thought the locale may of been incorrect perhaps in the language settings too.

That being said take a look at this:

https://invisioncommunity.com/developers/docs/fundamentals/dates-and-times-r165/

I'm not 100% sure how helpful that may or may not be however, I'm not a php dev. Hopefully if its not helpful one of our friendly authors here will be able to chime in with the correct details to use.

Posted

We use the localeDate() method to pull the custom field value, so it should use whatever locale is in use (caching aside - make sure the field/page/block/whatever isn't getting cached by a user from the US I suppose).

Posted
On 11/15/2018 at 2:57 PM, bfarber said:

We use the localeDate() method to pull the custom field value, so it should use whatever locale is in use (caching aside - make sure the field/page/block/whatever isn't getting cached by a user from the US I suppose).

Thanks, I've only got the US locale installed. Currently formatting on the client using moment.js

I see locale is set in the language file. How does that work with a user's locale? So, for example, how do I show a UK format date to UK visitors and US format to US?

Many thanks

Chris

Posted

Locale is set with the language pack, so you would just create two: one for English (UK) (or en_UK locale) and one for English (US) (or en_US locale). The text strings can be identical, or you can have fun and adjust the strings between the two (changing 's' and 'z' where appropriate for British English and so on, as the pack largely follows US English conventions out of the box).

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...