I’m in wordpress and write some php to get today’s day of the week in arabic language like الخمیس for thursday.
this is my code so far
function getWeekday() {
$dateName = date('l');
return date('w', strtotime($dateName));
}
echo getWeekday(); //today is monday and it echo's 2
if you know better way of codding to achive this is admirable.
2
Answers
You can’t use languages other than English with the standard
date
/DateTime
constructs in PHP. The only way to do this was to set the locale usingsetlocale()
and use thestrfttime()
function… however that function is now deprecated in favor of using the INTL/ICU extension’sIntlDateFormatter
class: