How it works
Apps Script ships two onEdit variants. The simple trigger (just a function named onEdit) fires on every edit but can't write to other documents. The installable trigger has the same name but is added explicitly via the Triggers panel — it can do almost anything.
For this script the simple trigger is enough: we only write within the same sheet. Apps Script auto-detects the function name and wires it up.
The three guards (column check, header check, deletion check) keep the trigger from firing on irrelevant edits. The B-cell-empty check makes the function idempotent — editing column A in an existing row won't overwrite a date that's already there.