How to get week days in php?

后端 未结 7 1540
小鲜肉
小鲜肉 2021-01-22 08:02

I want to get Monday, Tuesday, Wednesday... using php function.

I have only numeric values for those like 1,2,3..7 where

1 = Monday 2 = Tuesday ... 7 = Sunday.<

7条回答
  •  天命终不由人
    2021-01-22 08:46

    If you simply want to convert 0 to "Monday", 1 to "Tuesday", etc. use an array.

    $day_of_week = array
    (
        0 => 'Monday',
        1 => 'Tuesday',
        2 => 'Wednesday',
        .
        6 => 'Sunday'
    );
    
    $day = 2;
    
    echo $day_of_week[$day];
    

提交回复
热议问题