Skip to content

Instantly share code, notes, and snippets.

@mishaxz
Last active May 25, 2022 16:37
Show Gist options
  • Save mishaxz/fabfbb178fce3c94e12b1d6ff47ed880 to your computer and use it in GitHub Desktop.
Save mishaxz/fabfbb178fce3c94e12b1d6ff47ed880 to your computer and use it in GitHub Desktop.
CopyQ Script: Selected Date Text to yyyy-MM-dd
copyq:
if (!copy())
abort()
var text = str(clipboard())
text = text.replace("st","")
.replace("nd","")
.replace("rd","")
.replace("th","")
const yourDate = new Date(text)
const offset = yourDate.getTimezoneOffset()
yourDate = new Date(yourDate.getTime() - (offset*60*1000))
const dd = yourDate.toISOString().split('T')[0]
/* see: https://stackoverflow.com/questions/23593052/format-javascript-date-as-yyyy-mm-dd */
copy(dd)
paste()
@mishaxz
Copy link
Author

mishaxz commented May 25, 2022

note: it stopped working on v6 of Copy-Q... I was using 2.something before when it worked. I guess from around 2020. So try an older version.. maybe the most recent 2.x version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment