Sublime Text Plugin that provides a configurable command and popup for inserting the current date and time (with specific format)
Python JavaScript

InsertDate - Sublime Text Plugin

A plugin for Sublime Text 2 and 3 that inserts the current date and/or time according to the format specified, supporting named timezones.


For a brief introduction about the accepted formatting syntax, see Might yield different results, see below.


You must install this package with Package Control, under InsertDate.

Upon installation, you will be asked to select your local timezone. This is required for pretty formatting of the %Z variable and should be set, but InsertDate will work without it. You can change this setting at any time with the "InsertDate: Select Timezone" command from the command palette.


The quick panel (see gif) opens on F5 and shows a selection of pre-defined settings that can be modified. See Settings on how to do that.

However, there are many more default key bindings available to provide you with the most-needed formats and a command that allows you to insert your own format and output timezone on the fly.

Command Examples

The following is an excerpt of the default key bindings (on OSX: super instead of ctrl):

// Insert datetime using default format text
  { "keys": ["ctrl+f5", "ctrl+f5"],
    "command": "insert_date" },

// Insert datetime using the specified format
  // Locale date
  { "keys": ["ctrl+f5", "ctrl+d"],
    "command": "insert_date",
    "args": {"format": "%x"} },

  // Locale time
  { "keys": ["ctrl+f5", "ctrl+t"],
    "command": "insert_date",
    "args": {"format": "%X"} },

  // Full iso date and time
  { "keys": ["ctrl+f5", "ctrl+i"],
    "command": "insert_date",
    "args": {"format": "iso"} },

  // Locale date and time converted to UTC (with timezone name)
  { "keys": ["ctrl+f5", "ctrl+u"],
    "command": "insert_date",
    "args": {"format": "%c %Z", "tz_out": "UTC"} },

  // Unix time (seconds since the epoch, in UTC)
  { "keys": ["ctrl+f5", "ctrl+x"],
    "command": "insert_date",
    "args": {"format": "unix"} },

  // ... and many more

// Prompt for user input ("format" behaves as default text)
// and output timezone, if none provided,
// and then insert the datetime with these parameters
  { "keys": ["alt+f5"],
    "command": "insert_date_prompt" },

// Show the panel with pre-defined options from settings
  { "keys": ["f5"],
    "command": "insert_date_panel" }


Settings can be accessed using the menu (Preferences > Package Settings > InsertDate > Settings - User/Default) or the command palette ("Preferences: InsertDate Settings - User/Default").

You can also view the default settings here.

Format Examples

For the accepted formatting syntax, see for an introduction and datetime.strftime() behavior for all details. Note that the introduction uses a different library and thus may yield different results.

Here are some examples on how the values are interpreted:

Format string Parameters Resulting string
%d/%m/%Y %I:%M %p 12/08/2014 08:55
%d. %b %y 12. Aug 14
%H:%M:%S.%f%z 20:55:00.473603+0200
%Y-%m-%dT%H:%M:%S.%f%z 2014-08-12T20:55:00.473603+0200
iso {'tz_out': 'UTC'} 2014-08-12T18:55:00+00:00
%c UTC%z {'tz_in': 'local'} 12.08.2014 20:55:00 UTC+0200
%X %Z {'tz_in': 'Europe/Berlin'} 20:55:00 CEST
%d/%m/%Y %I:%M %Z {'tz_in': 'America/St_Johns'} 12/08/2014 08:55 NDT
%c %Z (UTC%z) {'tz_out': 'EST'} 12.08.2014 13:55:00 EST (UTC-0500)
%x %X %Z (UTC%z) {'tz_out': 'America/New_York'} 12.08.2014 14:55:00 EDT (UTC-0400)
unix 1407869700


  • CET is my actual timezone.
  • %c, %x and %X are representative for Locale’s appropriate time representation.
  • %p also corresponds to the locale's setting, thus using %p e.g. on a German system gives an empty string.

Snippet Macros

You can use the insert_date command in combination with snippets using macros. Here is an example:

    { "command": "insert_snippet", "args": {"contents": "Date: $1\nTime: $2\nSomething else: $0"} },
    { "command": "insert_date", "args": {"format": "%x"} },
    { "command": "next_field" },
    { "command": "insert_date", "args": {"format": "%X"} },
    { "command": "next_field" }

Check the documentation for Macros and Commands for further information.

Command Reference


Open a quick panel with pre-defined format settings


Insert the current date/time with specified formatting


  • format (str) - Default: '%c' (configurable in settings)

    A format string which is used to display the current time. See for an introduction and datetime.strftime() behavior for all details.

  • tz_in (str) - Default: 'local' (configurable in settings and recommended to change)

    Defines in which timezone the current time (read from your system) will be interpreted.

    May be one of these values or 'local'.

  • tz_out (str) - Default: None

    Defines on which timezone the output time should be based.

    By default, uses the same timezone as tz_in. May be one of these values or 'local' (which does not support %Z, but %z).


Open a small panel where you can specify the format string manually. The string passed in format will be used as default text if available. Accepts the same parameters as insert_date.