How to insert current date time in vscode?

前端 未结 7 1746
旧时难觅i
旧时难觅i 2020-12-24 01:27

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

相关标签:
7条回答
  • 2020-12-24 02:02

    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

    0 讨论(0)
提交回复
热议问题