The code only works with the new post. It will automatically add the desired date to the post. But for existing post, if i clear the date, and save it again, it will not work anymore. The date picker will just show the empty date (attached is the old post after clearing the date and updating it).
Thats because if the code has a date stored in the database it won't work.
This code is meant to work for posts without the date field already filled in. So if you were to remove date field value and save it wouldn't work because its detecting that their is a value for this field already there.
It only runs when the date field is empty.
I'm under the assumption that you only want this code to work when new posts are created to ensure that the dates are there.