Skip to content

Modify date shortcut for different format (yyyy-mm-dd) #28

Answered by jon-heard
jon-heard asked this question in Q&A
Discussion options

You must be logged in to vote

Go into the Inline Scripts settings and find the shortcut ^date$.

If you change the Expansion string from:

return new Date().toLocaleDateString();

to:

return new Date().toISOString().split("T")[0];

Then the shortcut should output in the format "yyyy-mm-dd".

Alternately, if you want more control over the output, this also works:

const d = new Date();
return d.getFullYear() + "-" + ((d.getMonth()+1)+"").padStart(2, 0) + "-" + (d.getDate()+"").padStart(2, 0);

Replies: 1 comment

Comment options

jon-heard
Aug 13, 2022
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by jon-heard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant