How to get week days in php?

后端 未结 7 1454
小鲜肉
小鲜肉 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:36

    My personal favorite...

    $day_start = date( "d", strtotime( "next Sunday" ) ); // get next Sunday
    for ( $x = 0; $x < 7; $x++ )
        $week_days[] = date( "l", mktime( 0, 0, 0, date( "m" ), $day_start + $x, date( "y" ) ) ); // create weekdays array.
    

提交回复
热议问题