Skip to content

Instantly share code, notes, and snippets.

@kebman
Created December 31, 2025 05:06
Show Gist options
  • Select an option

  • Save kebman/4d4883bfee9d4e4d13056cd1baa21dd8 to your computer and use it in GitHub Desktop.

Select an option

Save kebman/4d4883bfee9d4e4d13056cd1baa21dd8 to your computer and use it in GitHub Desktop.
Sublime Text Plugin β€” Insert ISO Date & Time Timestamps πŸ•”

Sublime Text Plugin β€” Insert ISO Date & Time Timestamps πŸ•”

This small Sublime Text plugin adds three commands:

  1. Insert current date β†’ YYYY-MM-DD
  2. Insert current time β†’ hh:mm (24-hour)
  3. Insert date + time β†’ YYYY-MM-DD hh:mm

Works both for inserting and replacing a selection.


1️⃣ Create the plugin file

In Sublime Text:


Tools β†’ Developer β†’ New Plugin…

Replace the contents with:

import sublime
import sublime_plugin
from datetime import datetime


def insert_text(edit, view, text):
    for region in view.sel():
        if region.empty():
            view.insert(edit, region.begin(), text)
        else:
            view.replace(edit, region, text)


class InsertIsoDateCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        insert_text(edit, self.view, datetime.now().strftime("%Y-%m-%d"))


class InsertIsoTimeCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        insert_text(edit, self.view, datetime.now().strftime("%H:%M"))


class InsertIsoDatetimeCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        insert_text(edit, self.view, datetime.now().strftime("%Y-%m-%d %H:%M"))

Save as e.g.:

InsertTimestamps.py

Sublime reloads plugins automatically.


2️⃣ Run via Command Palette

Press:

  • Ctrl+Shift+P (Windows / Linux)
  • Cmd+Shift+P (macOS)

Then type:

  • Insert Iso Date
  • Insert Iso Time
  • Insert Iso Datetime

3️⃣ Optional β€” Keybindings

Open:

Preferences β†’ Key Bindings

Add something like:

[
    { "keys": ["ctrl+alt+d"], "command": "insert_iso_date" },
    { "keys": ["ctrl+alt+t"], "command": "insert_iso_time" },
    { "keys": ["ctrl+alt+shift+t"], "command": "insert_iso_datetime" }
]

Change bindings to whatever suits your workflow.


βœ… Done

You now have quick-insert ISO timestamps in Sublime Text.

If you want variations, the formats can easily be changed to include:

  • seconds / milliseconds
  • UTC timestamps
  • full ISO-8601 YYYY-MM-DDTHH:mm
  • RFC-3339 style output

Just edit the strftime() strings in the plugin.

Other Alternatives

This is a very minimal plugin. If you want something more serious, consider either InsertDate or Timenow from Package Control.

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