TextExpander logo TextExpander Smile logo
 

Help: Date, Time, and Math Macros


Date / Time Snippets

Create a date or time snippet using the Insert menu

  1. Create a new snippet by clicking New Snippet new snippet button in the TextExpander menubar.
  2. Click the Insert menu insert menu button located just above the Abbreviation box. You will see both Date and Time options.
  3. Select a series of Year, Month, Day or Hour, Minute, Second options. Include any punctuation you would like.

    For example, if you want a date to appear in this format “January 3, 2012”, insert the following:

    • Choose Date > Month > January. Add a space.
    • Choose Date > Day > 1. Add a comma and a space.
    • Choose Date > Year > 2001
  4. Choose an abbreviation in the Abbreviation box. We like abbreviations like “ddate” and “ttime”.

How date / time snippets work

TextExpander allows you to create snippets which expand the current time and date. These types of snippets use special codes (macros) to do so, and are easily customizable.

For example, TextExpander comes with a sample snippet, “ddate”, for the current date. Type the abbreviation, “ddate”, and the current date will appear like this : January 3, 2012 ¬†(assuming this is the current date).

Each portion of the date is represented by a percentage sign and letter combination (macro), each of which stands for a particular format for showing Month, Day, and Year. In order to change a given date format, change the macros involved and their order. For example:

    For this date format “January 3, 2012”, where Month is a word, Day is a number, and Year is a number, use these characters “%B %e, %Y”.

    For this date format “12-01-03”, where Year is a number, Month is a number, and Day is a number, use these characters “%y-%m-%d”.

The following is a list of macros that can be used in TextExpander in date and time snippets:

  • Time

    %1H = Hour, 24-hour clock, 1-2 digits (0-23)

    %H = Hour, 24-hour clock, 2 digits (00-23)

    %I = Hour, 12-hour clock, 2 digits (00-12)*

    %1I = Hour, 12-hour clock, 1-2 digits (0-12)*

    %M = Minute, 2 digits (00-59)

    %1M = Minute, 1-2 digits (0-59)

    %S = Second, 2 digits (00-59)

    %1S = Second, 1-2 digits (0-59)

    %p = Time, AM/PM

    %z = GMT offset

    %Z = timezone

*Note the codes for 12-hour clock use a capital letter i

  • Date

    %Y = Year, 4 digits (2011)

    %y = Year, 2 digits (11)

    %B = Month, long name (January)

    %b = Month, short name (Jan)

    %m = Month, 2 digits (01-12)

    %1m = Month, 1-2 digits (1-12)

    %A = Day, long name (Monday)

    %a = Day, short name (Mon)

    %d = Day, 2 digits (01-31)

    %e = Day, 1 digit (1-31)

    %j = numerical day of year

    %date:<Unicode Date Format>%

(where <Unicode Date Format> is defined here: http://unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns)

Date / Time Math

Make a snippet to show a past or future date or time using math macros. This involves placing a math macro directly in front of a date or time macro. Date/time macros are explained above. For example, say you are in the Accounts Receivable department and routinely need to remind people to pay you in 15 days time. You can create a date snippet that will always expand to a date 15 days in the future.

Create a snippet using date / time math:

  1. Create a new snippet by clicking on New Snippet new snippet button in the TextExpander menubar.
  2. Click on the Insert menu insert menu button located just above the Abbreviation box. Navigate to Date/Time Math > Add Day(s).
  3. TextExpander inserts the special code¬†%@+1D, aka math macro, into your snippet content. Change “1D” to “15D”.
  4. Insert the date format you wish to appear using the Insert menu, located just above the Abbreviation box. For example, if you want the date to appear in this format “January 3, 2012”, insert the following:
    • Choose Date > Month > January. Add a space.
    • Choose Date > Day > 1. Add a comma and a space.
    • Choose Date > Year > 2001
  5. When you are done, the snippet content should be “%@+15D%B %e, %Y”, without the quotation marks.
  6. Give your snippet an abbreviation, such as “d15” or “payupnow”.

date math submenu

Here is a list of the math macros used in TextExpander:

  • %@+1Y = Add Year(s)
  • %@+1M = Add Month(s)
  • %@+1D = Add Day(s)
  • %@+1h = Add Hour(s)
  • %@+1m = Add Minute(s)
  • %@+1s = Add Second(s)

To subtract the value instead of add, change the plus “+” to minus “-”. To change the amount of value, change the “1” to another number.

Date and time math macros apply to all subsequent date and time formats, including to embedded snippets. Date and time math macros are not cumulative. If another date and time math macro appears in a snippet, it replaces the previous date and time math macro. For example, assuming it is now September 2014: "One year from now: %@+1Y%Y, more specifically %B, %Y. Two years from now: %@+2Y%Y." expands to "One year from now: 2015, more specifically September, 2015. Two years from now: 2016."

For more information on special characters and macros used in TextExpander, see Advanced Snippet Functions: Macros.

 
 
© 2006-2015 SmileOnMyMac, LLC, dba Smile. All rights reserved.
TextExpander is a registered trademark, Smile and the Smile logo are trademarks of SmileOnMyMac, LLC, dba Smile.