Jump to content

Best practice for date / time field formatting?


Webrocker
 Share

Recommended Posts

Hi and Happy New Year to you all :-)

I'm currently reviewing some of my first sites, esp. regarding better usability for the backend users/editors.

One thing I use often is to set the infos displayed in the tree/listing view, for example have not only the title, but also the category or the published date visible.

Now, if the format of the date field is not set in the template settings, this will display the unix timestamp, which is not so comfortable for the editor. But if I set the format, this will influence how the date is displayed in the front end, which may be too inflexible, for example if the field is used in different templates, maybe with a short and a complete date display.

I decided to use the unformatted date and format it to my needs in the front end templates. but as said, this makes the backend display of the date unusable for the editor.

Now upon revisiting this situation, I wonder if it would be better to use a (pre set) format that's suitable for my back end editors needs, and make a strtotime/strftime formatting in the frond end templates to change the date format if needed.

How is your approach to this, or how is the set-date-format at field level thing intended to be used?

cheers,

Tom

Link to comment
Share on other sites

Set the format to a sensible default and use this in the frontend to get the timestamp for other formatting purposes:

// 1452082822
$timestamp = $page->getUnformatted("dateField");
// 01/06/2016 12:20
$defaultFormat = $page->dateField;
  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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