PHP day of week numeric to day of week text

前端 未结 7 648
不思量自难忘°
不思量自难忘° 2020-12-01 11:33

This may be really easy but I can\'t find a PHP function to do this...

OK so

$dow_numeric = date(\'w\');

gives the numeric day of t

7条回答
  •  隐瞒了意图╮
    2020-12-01 12:25

    If you need locale support you can use a bit improved function of Hamishs answer:

    Example using german weekdays:

    setlocale(LC_TIME, 'de_DE');
    $dow_numeric = 3;
    $dow_text = strftime('%A', strtotime("Sunday +{$dow_numeric} days"));
    

    http://php.net/strftime

    If $dow_numeric start on 0 (0 = Monday) you can just change Sunday to Monday or add $dow_numeric += 1

提交回复
热议问题