Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Translating PHP weekdays and months

Any ideas for translating PHP weekdays and months to local language? I have script which prints weekdays of next 5 weeks and I want that they are in other language.

$timestamp = strtotime('next Monday');
for ($i = 0; $i < 35; $i++) {
    echo strftime('%A', $timestamp)." ";
    $timestamp = strtotime('+1 day', $timestamp);
}

Is there any good integrations e.g. with PHP and moment.js? I have looked at Use PHP's date() formats in moment.js and GitHub fightbulc/moment.php , but I don't understand how to use those..

Thank you in advance.

like image 870
lingo Avatar asked Dec 25 '15 18:12

lingo


1 Answers

You are probably looking for the following:

http://php.net/manual/en/function.setlocale.php

http://php.net/manual/en/function.strftime.php

UPDATE

setlocale(LC_TIME, "fi");
echo utf8_encode(strftime('%A'));

RESULT

perjantaina

And this as a gift for you guys - the ISO language codes

like image 179
Alaa M. Jaddou Avatar answered Sep 30 '22 06:09

Alaa M. Jaddou