Reputation: 1344
I have a variable $date='15-06-2013'
. Now, how do I get the number of the day in the week? 15-06-2013 is a Saturday
and hence my function should return 6
as the number if I were to use N
format character
Upvotes: 1
Views: 104
Reputation: 18440
Alternatively, using the DateTime class:-
echo (new \DateTime('15-06-2013'))->format('N');
Output:-
6
Upvotes: 0
Reputation: 30488
Use this code
echo $day_of_week = date('N', strtotime('15-06-2013'));
6
Upvotes: 2