Forum

Thread tagged as: Question, Blog

Format the blog date in German

Hello guys,

I'm creating a blog in German language and so I need to set the date output instead of 14.July 2016 to 14.Juli 2016.

The problem is that I don't know how to do this exactly.

thanks in advance Daniel

Daniel Pointecker

Daniel Pointecker 0 points

  • 5 years ago

Hi,

You can use local-compatible dates, this is some info:

https://docs.grabaperch.com/docs/templates/attributes/type/date/

https://www.php.net/manual/en/function.strftime.php

So in your example I think you would need

<perch:content id="date" type="date" label="Post Date" format="%e %B %Y" />

Thanks Mike,

sorry but I do not understand what to do exactly. Where do I have to set the locale?

No problem - you can do it in config.php - try adding this line:

setlocale('LC_ALL', 'de_DE');

Test locally before going live though!

does not work, I did set this in config.php

For better understanding this is the code of my blog template;

<perch:before>

<ul class="hfeed listing col-12"></perch:before>
    <li class="hentry col-12 col-4-m">
        <perch:if exists="image"><a href="<perch:blog id="postURL" />" rel="bookmark" class="entry-title"><img src="<perch:blog id="image" type="image" width="320" height="240" crop="true" label="Image" order="4" />" alt="<perch:blog id="postTitle" />" /></a></perch:if>
        <h2><a href="<perch:blog id="postURL" />" rel="bookmark" class="entry-title"><perch:blog id="postTitle" /></a></h2>
        <div class="seperator klein"></div>
        <div class="description entry-summary">
        <perch:blog id="excerpt" type="textarea" textile="true" />
        </div>
        <div class="blog-datum">
            <p class="entry-published date"><perch:blog id="postDateTime" time="local"  format="%d.%B %Y" /></p>
        </div>
    </li>
<perch:after>
    </ul>
    <perch:if exists="paging">
        <div class="paging">
            Page <perch:blog id="current_page" /> of <perch:blog id="number_of_pages" />
            <perch:blog id="page_links" encode="false" />
            <perch:if exists="not_first_page">
                <a href="<perch:blog id="prev_url" encode="false" />">Previous</a>
            </perch:if>
            <perch:if exists="not_last_page">
                <a href="<perch:blog id="next_url" encode="false" />">Next</a>
            </perch:if>
        </div>
    </perch:if>
</perch:after>

The output in the frontend is still 14.July 2016

Drew McLellan

Drew McLellan 2638 points
Perch Support

You may need to use de_DE.UTF-8.

Make sure you save your content after changing the locale to clear its cache.