Format the date properly before saving