在特定日期和年份的第一个星期六

i have code in php,the function of first saturday in this month

date_default_timezone_set('Asia/Jakarta');
$dt             = new DateTime('first Saturday of this month');
$periode        = $dt->format('Y-m-d');

it's mean that the result is first saturday of this month(july), but i want to get first saturday of january 2015,so i change my code being

$dt             = new DateTime('first Saturday of January 2015');

but it has wrong result. help me please

You can use strtotime, also see the ref in PHP Manual

echo date('d-m-Y', strtotime('first sat of jan 2015'));

Unfortunately programming languages like PHP don't process natural language like this (at least not reliably. if it works you wouldn't be asking this question). You will have to formulate your function differently to get a more deterministic result.

I have answered your other question, which is almost identical to this one, but here it is again:

function stamp_of_first_saturday($year,$mon){
  $base=mktime(0,0,0,$mon,1,$year);
  $dow=date('w',$base);
  $sat=(6-$dow)*3600*24+$base;
  return $sat;
}

echo date('Y-n-j', stamp_of_first_saturday(2015,7) );