Adjusting Default Time for Date Fields

Kevin Flanagan
Feb32019

Have you ever noticed how messy a UI looks when you try to set a default date field into the future by say, a day, a week or a month?  What you get is a full-time date assumption, right down to the second, anticipating what the rest of that date must be. This happens of course because that is what you are looking for ..... that particular moment that occurs +1 weeks from this very moment.

So you do you make a default date and time that is relatively more ergonomic than a date of say, January 21st, 2021 10:21 am? Something more like: March 17th, 2020 4:00 pm?

 You need to account for the hour, minute and second of this very moment and also account for where your relative time zone is set within the Drupal configuration.

+ 1 weeks - 1 today + 20 hours

This is the default formula I used in a date field to set the default to be 1 week at 4 pm in the afternoon from today's date.  By subtracting the value of 'today' from the value of "+1 weeks", I'm getting a time at midnight, GMT for a given date, 6 days into the future.  By adding on the appropriate number of hours to offset the timezone difference, you can get the desired default hours.  You best approach is to hunt and peck for that perfect offset hours.