I'm trying to port over to Laravel a feature that I built in PHP where a user can enter approximate dates. The way it works in PHP is that it there are 2 dropdown menus (1 for month and 1 for days) and a text input for year. The month dropdown has all of the months plus "Fall", "Winter", "Spring" and "Summer and a month value. The days dropdown has all of the days in a month with leading zeros.
When the user hits submit, everything is aggregated:
$year.'-'.$month.'-'.$day
The month value has months with leading zeroes but for seasons it assigns a month to it so that the date can be written and used for sorting purposes.
Then, if the day isn't filled in, Fall 2016 (for example) would be written to a text field. Or if they chose a month in the drop down, September 2016. In those cases, the date would be written as 2016-09-00 in the date field so that it can used to sort. In my code the text field would be displayed through a conditional statement (if text field is not empty).
When the date is edited, whether the approximate date is written or not is dependent on whether the day is 00.
This is has worked great in PHP for years. It's complicated but it works. But in Laravel, if the input is 00 for a day, it defaults to the last day of the calendar month.
Now that I'm migrating the site to Laravel, I need to find a workaround.
How have others handled approximate dates?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community