5

Is there any PHP function that returns the date of the first week ,

i:e, if i pass "Monday" , it should return 02 of september,
i know, how to get the day, month, date like

date('l') , date('m'), date ('d') 

But stuck at this point

j08691
  • 204,283
  • 31
  • 260
  • 272
Irfan Ahmed
  • 9,136
  • 8
  • 33
  • 54

2 Answers2

7

This should get you started:

$dt = new DateTime('first Monday of this month');
echo $dt->format('l m d');

See it in action

John Conde
  • 217,595
  • 99
  • 455
  • 496
1

You can use strotime(), like so:

function getDateFromDay($day) {
    return date('d-m-Y', strtotime("first $day of this month"));
}

Usage:

echo getDateFromDay('Monday');

Output:

02-09-2013

Demo!