Useful Snippets

Welcome!


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

RSS Latest posts from my personal blog


Most viewed posts


Subscribe to RSS feed


Format a date using the correct language in WordPress

Stanislav KhromovStanislav Khromov

To format a date and have it output the time in the language which is configured in WordPress, use the date_i18n function.

It uses the same parameters as date().

Example

Before

date('j F', time());

After

date_i18n('j F', time());

Web Developer at Aftonbladet (Schibsted Media Group)
Any opinions on this blog are my own and do not reflect the views of my employer.
LinkedIn
Twitter
WordPress.org Profile
Visit my other blog

Comments 4
  • mhornet13
    Posted on

    mhornet13 mhornet13

    Reply Author

    JUST thnx!!!!


  • alp
    Posted on

    alp alp

    Reply Author

    Thank you, I fixed my date language problem thanks to your article.

    Btw, I would like to ask another question about language. How could I fix these words =>”by, on, comments”?

    Do you have any language trick or must I fix manually?

    Thanks,
    Best regards,
    Alp


  • Steffen Gammelgaard
    Posted on

    Steffen Gammelgaard Steffen Gammelgaard

    Reply Author

    Thanks! Just what I needed :D


  • HJ
    Posted on

    HJ HJ

    Reply Author

    Where to add this???