3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Returns the day name according to the current locale * * @param int $n The day number (ISO-8601 numeric representation) * @param string $lc The desired locale for the returned day name * * @return string The day name */ function day_name(int $n, string $lc = "en_GB") { // Store the current locale so that we can reset it $olc = setlocale(LC_TIME, "0"); // Set the locale according to the $locale passed in setlocale(LC_TIME, $lc); // Get the day name according to the $locale passed in $output = strftime("%A", strtotime("Last Sunday +{$n} days")); // Reset the locale setLocale(LC_TIME, $olc); // Return the day name return $output; } echo day_name(4, "fr_FR");

preferences:
55.28 ms | 402 KiB | 5 Q