This can be done using Javascript’s Date object. Something like:
// #popclip
// name: Date to ISO
// icon: ISO
// language: javascript
// after: paste-result
const date=new Date(popclip.input.text);
return date.toISOString().slice(0, 10);
(The above block is an extension snippet — select it then click “Install Extension” in PopClip.)
Notes:
- JS’s Date() constructor accepts an arbitrary string and will attempt to parse it as a natural language string.
toISOString()
produces output like2023-12-03T00:00:00.000Z
- so we use string
slice()
to cut off the first 10 characters only to get the ISO date part.