I have a working template file that has the date hardcoded as shown below –
$spring_date_end = strtotime($key."-04-01");
I want to insert the value of the date picker (from an options page) to replace this section of code “-04-01”
The date pickers are set to the Return Format= /m/d/
the_field('spring_term_dates_start' , 'options');
The fields are returning the date on the front end as= /01/04
current fields I have in place
spring_term_dates_start
spring_term_dates_end
summer_term_dates_start
summer_term_dates_end
autumn_term_dates_start
autumn_term_dates_end
Sample code section –
// My section of working code
// $key = $year
$result = array();
foreach($posts_by_year as $key => $year){
foreach($year as $y){
$date = strtotime($y['date']);
list($ny,$nm,$nd) = explode('-',$y['date']);
$spring_date_start = strtotime($key."-01-04");
$spring_date_end = strtotime($key."-04-01");
if($date >= $spring_date_start && $date <= $spring_date_end){
$Season = 'Spring';
}
$summer_date_start = strtotime($key."-04-02");
$summer_date_end = strtotime($key."-08-31");
if($date >= $summer_date_start && $date <= $summer_date_end){
$Season = 'Summer';
}
$autumn_date_start = strtotime($key."-09-01");
$autumn_date_end = strtotime(($key+1)."-01-03");
if($date >= $autumn_date_start && $date <= $autumn_date_end){
$Season = 'Autumn';
}
if($nm == '01' && in_array($nd,array('01','02','03'))){
$Season = 'Autumn';
}
$result[$key][$Season][$y['term']][] = $y;
}
}
I can’t work out how to replace the hardcoded date with the date picker field value whilst including the $key. ?