Date Time Shortcut
When writing Markdown in VS Code it’s useful to be able to insert the current date and time quickly. You can do this by setting up a keyboard shortcut1 that inserts the current date and time in a specific format.
To set up a date time shortcut in VS Code, follow these steps:
Open the command palette by pressing
Ctrl+Shift+P(orCmd+Shift+Pon macOS).Type “Preferences: Open Keyboard Shortcuts (JSON)” and select it.
Add the following JSON snippet to your
keybindings.jsonfile}, { "key": "ctrl+d t", "command": "editor.action.insertSnippet", "when": "editorTextFocus", "args": { "snippet": "$CURRENT_YEAR-$CURRENT_MONTH-${CURRENT_DATE}T$CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND.000" } }Save the file.
Now, whenever you press
Ctrl+d t(or your chosen key combination), it will insert the current date and time in the formatYYYY-MM-DDTHH:MM:SS.000.