Refactor and share code with set_date_and_time (only difference is key sent).