1

I am working on a project where the content manager can add events (entries). These events have a date, starting time and end time. The fields in the cms show the option for adding a date, time and time accordingly.

To print them in HTML I do this.

Date

<p>{{entry.datum}}</p>

Starttime

<p>{{entry.begintijd}}</p>

Endtime

<p>{{entry.eindtijd}}</p>

However, only the date is shown, like this:

2014-11-30

2014-11-30

2014-11-30

How do I format the result so I get the times in a format like 15:00?

Also, how do I format the date to be shown in Dutch time format, like 1 januari 2015?

Thanks in advance

3

You can use the Twig .format() filter to achieve exactly what you are looking for, the reference page for date and time values is here.

So if you would like the date format to show 15:00, you can use:

<p>{{ entry.lorem.format('H:i') }}</p>

And the date format for 1 Januari 2015 will be as follows:

<p>{{ entry.lorem.format('j F Y') }}</p>

As I say, you can reference the website for which values to use.

  • A bit of a late reply, but I wanted to thank Jamie Wade for the answer! – Evin Wijninga Jan 18 '15 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.