Of course it is ![]()
Instead of my original way to get a dateString
const dateString = date.toLocaleDateString("en-US", { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute:'2-digit', second: '2-digit', hour12: false }).replaceAll(/[:\/ ]/g,"-").replace(",","");
I’ve now seen the light and suggest
const dateString = date.toISOString().replaceAll(/[:T]/g,"-").replace(/\.*$/,,"");```
date.toISOString returns something like 2011-10-05T14:48:00.000Z. The first replace call changes the colons and the T to dashes, the second one removes the point and everything after it. So it is a tiny bit more elegant than the AppleScript way, after all.