Question

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

Was it helpful?

Solution

Use this code

echo $day_of_week = date('N', strtotime('15-06-2013'));

Output

6

Codepad

OTHER TIPS

Alternatively, using the DateTime class:-

echo (new \DateTime('15-06-2013'))->format('N');

Output:-

6

See it working

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top