Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get day number of the week of current month's first day in PHP

Tags:

date

php

I want to get day number of week of the current month. For example

to day

Sep. 1st, Monday 

should return 1

Oct. 1st, Wednesday

should return 3

21.11.2014

should return 6

like image 462
zkanoca Avatar asked Jan 10 '23 22:01

zkanoca


1 Answers

Try this:

var_dump(date('N', mktime(0, 0, 0, date('n'), 1)));

It's not clear from your question whether your input is a string or whether the function should assume the current month/year that is right now.

like image 196
silkfire Avatar answered Jan 27 '23 22:01

silkfire