3

I was wondering if there is a way to use the locale in strftime to echo all days of the week, regardless of date. To use as sort of headings or titles and rather than using constants and loading the correct one.

i.e.

setlocale(LC_TIME, "de_DE");
echo strftime("%A", 1); //echos Monday
echo strftime("%A", 2); //echos Tuesday
echo strftime("%A", 3); //echos Wednesday

so that all I need to do is change the locale for a different language.

Thanks

Stevanicus
  • 7,561
  • 9
  • 49
  • 70

2 Answers2

1

You could alternatively create a simple for loop:

for ($i=0;$i<7;$i++) {
      $weekday[] = strftime('%a ', mktime(0, 0, 0, 6, $i+2, 2013));
    }
print_r($weekday);
Remi
  • 4,663
  • 11
  • 49
  • 84
1
setlocale(LC_TIME, "de_DE");
echo strftime("%A", strtotime("next Sunday"));
echo strftime("%A", strtotime("next Monday"));
echo strftime("%A", strtotime("next Tuesday"));
echo strftime("%A", strtotime("next Wednesday"));
echo strftime("%A", strtotime("next Thursday"));
echo strftime("%A", strtotime("next Friday"));
echo strftime("%A", strtotime("next Saturday"));
malonso
  • 2,247
  • 1
  • 21
  • 33