Does anyone know of a way that I can insert the current date & time in a visual studio code by snippets?
I have looked docs but did not get any information abou
For more complex datetime expressions than vscode snippets can do, see Command Variable extension. It uses the Intl.DateTimeFormat
format and can be used in a keybinding like so:
{
"key": "alt+d",
"when": "editorTextFocus",
"command": "extension.commandvariable.dateTimeInEditor",
"args": {
"locale": "en-US",
"options": {
"year": "numeric",
"month": "long",
"weekday": "long",
"day": "2-digit",
"hour12": false,
"hour": "2-digit",
"minute": "2-digit",
"second": "2-digit"
},
"template": "${month} ${day}, (${weekday}), ${year} - ${hour}:${minute}::${second}"
}
},
to produce
March 25, (Wednesday), 2020 - 21:16::49
and many other timestamp versions. See the possibilities at Intl.DateTimeFormat