date - How to get first, third and fifth Saturday of a month in PHP? -


i have found solution problem, it's getting wrong condition. following findings:

this code segment print first saturday of august 2015 , july 2015:

$sat = date("f y",strtotime("2015-08-01")); echo $fir_sat = "$sat first saturday"; echo " ".date('d', strtotime($fir_sat));  $sat = date("f y",strtotime("2015-07-04")); echo $fir_sat = "$sat first saturday"; echo " ".date('d', strtotime($fir_sat)); 

following output:

august 2015 first saturday 08 july 2015 first saturday 04 

but 01:

august 2015 first saturday 01 

how happen? solution?

based on feedback's have tried coding. following findings. error happened because of php version.

in lower version of php 5.2.9 following code not working

echo date('y-m-d', strtotime('first saturday of august 2015'));

but in higher version 5.4 wokring

any ideas?

try using of as

echo date('d f y', strtotime('first saturday of $fir_sat')); 

"ordinal dayname 'of' " not advance day.

instead of

echo date('d f y', strtotime('$fir_sat first saturday')); 

"ordinal dayname " advance day.

you can check difference on here

you can check docs(notes)


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -