Support » Fixing WordPress » strftime() and get_the_date(), what is wrong?

  • Hey

    It was sent as Thai, but now it appears 2018.
    setlocale(LC_TIME, “th_TH.UTF-8”);
    echo strftime(“%A %e %B %Y”);

    Yes, it says now 2017, but that is now only english
    echo get_the_date(“l j. F Y”); //WordPress

    Why does this happen?

Viewing 5 replies - 1 through 5 (of 5 total)
  • w


    strftime gives your the current time, while get_the_date gives you the publishing date of the post.

    yes, but why?
    strftime in thai, but 2018.
    get_the_date to 2017, but English.
    I want give it to thai, and 2017.

    get_the_date ignores php locales (it uses probably lang settings from admin panel).

    You can try this solution:

    setlocale(LC_TIME, “th_TH.UTF-8”);
    echo strftime("%A %e %B %Y", get_post_time('U'));

    or You can set thai language for the whole site in admin panel.

    Thank you 🙂

    “วันพุธ ที่ 2 มีนาคม พ.ศ. 2016”, how much I can add with “วันพุธ ที่ ๒ มีนาคม พ.ศ. ๒๐๑๖” and with 2559 to ๒๕๕๙?

    • This reply was modified 2 years, 6 months ago by TheDani.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘strftime() and get_the_date(), what is wrong?’ is closed to new replies.