I'm trying to make use of the custom date interval field. Thanks for the provided PHP example! However, with my limited knowledge of PHP, I'm unable to adapt it to my needs.
What I want: to make users choose between different ages of documents. I need a selection of:
- a week (seven days backwards from the then current date)
- a month
- a year
- two years
- five years
- doesn't matter (any date between now and the beginning of time, 1980 or a similar year would be sufficient )
What I've tried:
$currentDate = date('Y-m-d');
$intervalDates = [
$currentDate.'|'.date('Y-m-d', time()-604800) => "a week",
$currentDate.'|'.date('Y-m-d', time()-2678400) => "a month",
$currentDate.'|'.date('Y-m-d', time()-31536000) => "a year",
$currentDate.'|'.date('Y-m-d', time()-63072000) => "two years",
$currentDate.'|'.date('Y-m-d', time()-157680000) => "five years",
];
I know it's probably not elegant, but also it's not working.
Do you have any suggestions to improve my beginners code?
Best regards,
Sebastian