Date Stamp solution needed

Hi,
Almost daily, I type the date in my notes, and multiple times. Is anyone aware of a simple utility/app that allows you to paste or otherwise insert the current date into any application’s text fields?

I am hoping for this format:
“05/02/23”

As a relevant aside: I tried creating Automator actions with Applescripts, but my results were inconsistent. And reading a few forum discussions, I’m not sure it’s possible via an Automator action anymore.

If anyone is curious, this action provided the best results, but then it stops working once you copy/paste anything else after this. I found this solution via this Apple forum post.

I ran this via a keyboard shortcut, and then pasted the results into any text field.

on run {input, parameters}
	set the clipboard to (do shell script "date +'%m/%d/%y'': '")
end run

And these were my settings:

Would something like Text Expander work here? I use it to insert dates in file names and forms by just typing a couple of characters.

4 Likes

TextExpander works

Keyboard Maestro can do this too.

Brett Terpstra has a great utility that can do almost anything you want with dates, including turning natural language (“next Tuesday”) into a date in a particular format. It uses Keyboard Maestro under the hood. Make A Date for Keyboard Maestro - BrettTerpstra.com

4 Likes

I do this with Alfred Snippets. For your preference it would be

{date:MM/dd/yy}

Other options after the “:” are documented at

http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns
4 Likes

I use Typinator (https://ergonis.com/typinator) (this is a paid software). Earlier, I was using Keyboard Maestro as well.

In addition to what others have suggested, Espanso (free alternative, open-source)

https://espanso.org


Here’s how my Typinator shortcuts look like (for my specific use cases)

1 Like

If you wanted to insert using a key combination rather than type the abbreviation, then Keyboard Maestro would be something to look at.

1 Like

In BTT (BetterTouchTool) I have a “key sequence” configured like this:

Screenshot 2023-05-03 at 14.41.58
Screenshot 2023-05-03 at 14.42.06

1 Like

I use Espanso (free, open-source) for this. I have a number of shortcuts:

  • ;today generates May 3, 2023
  • ;fdate or ;ddate generates Wednesday, May 3, 2023
  • ;now or ;odate generates 3rd day of May, 2023
  • ;date opens a dialog box where I can enter any date (in YYYY-MM-DD or MM-DD format) and select from any of the above formats. It then inserts the given date in the selected format.

Note that the last two require a Python script to work, although, you can use any scripting language. I just happen to prefer working in Python. I needed the script for ordinal dates (1st, 2nd, 3rd, 4th…), which I use regularly. If you don’t need that, then the script is not necessary.

The relevant section of my config file which implements the above looks like this:

  # Today (January 1, 2021)
  - trigger: ";today"
    replace: "{{date}}"
    vars:
      - name: date
        type: date
        params:
          format: "%B %e, %Y"
    
  # Full/Day Date (Friday, January 1, 2021)
  - triggers: [";fdate", ";ddate"]
    replace: "{{ddate}}"
    vars:
      - name: ddate
        type: date
        params:
          format: "%A, %B %e, %Y"

  # Ordinal Date (1st day of January, 2021)
  - triggers: [";now", ";odate"]
    replace: "{{formated_date}}"
    vars:
      - name: dateform_format
        type: echo
        params:
          echo: "Do [day of] MMMM, YYYY"
      - name: formated_date
        type: script
        params:
          args:
            - python
            - "%CONFIG%/scripts/format_date.py"

  # Date from form
  - trigger: ';date'
    replace: "{{formated_date}}"
    vars:
      - name: dateform
        type: form
        params:
          layout: |
            Date: {{date}}
            Format: {{format}}
          fields:
            format:
              type: list
              values: 
                - "MMMM D, YYYY"
                - "dddd, MMMM D, YYYY"
                - "Do [day of] MMMM, YYYY"
      - name: formated_date
        type: script
        params:
          args:
            - python
            - "%CONFIG%/scripts/format_date.py"

And this is my Python script:

import arrow
import re
import os

YEAR_RE = re.compile(r'^\d{4}')

def normalize(date_str):
    sep = ''
    if '/' in date_str:
        sep = '/'
    elif '-' in date_str:
        sep = '-'
    elif '.' in date_str:
        sep = '.'
    if len(date_str) < 6 and not YEAR_RE.match(date_str):
        # Date is (probably) missing year. Use current year.
        year = arrow.now().format('YYYY')
        date_str = f'{year}{sep}{date_str}'
    return date_str

def format_date(date_str, format):
    date = arrow.get(normalize(date_str))
    return date.format(format)

def get_args():
    date = os.environ.get('ESPANSO_DATEFORM_DATE', arrow.now().format(arrow.FORMAT_RFC3339))
    format = os.environ.get('ESPANSO_DATEFORM_FORMAT', 'MMMM D, YYYY')
    return date, format

if __name__ == '__main__':
    print(format_date(*get_args()))
2 Likes

Thank you so much for your replies! I am playing with a couple of your suggestions, and Typinator is the quickest to just work intuitively right now as a date stamp. I also am liking some of their other features, many of which I could use frequently.

Example: copying and pasting “clean” (ie. unformatted) items from the clipboard. I usually have to copy and paste into a Chrome URL field to get clean text, so just being able to type in two letters is so much easier!

Thanks so much! Typinator just worked right away, to create the time stamp. I started playing with Keyboard Maestro but the interface is too dense for the moment. I also couldn’t find any built-in “date” or “time” stamps when I used their search field.

1 Like

Lots of ways, but I’d like to point yet another alternative that is free and does much more than insert dates. Download the apps WordService and also while you are at it CalcService. Created by the DevonThink folks. These create numerous macOS Services. They can be launched from a keyboard shortcut you can set in System Settings, or often from the Context Menu if not blocked by the application.

Consider this the “old school” approach. WordService has been around since 2001.

3 Likes

One more option, you can do this in Raycast via snippets

https://manual.raycast.com/snippets

1 Like

I use Typinator and it works great.

If you want or need a free alternative, Devonthink publishes some freeware, including WordService, which does some magic on text, and has the bonus of allowing you to insert dates and times, or variations thereof. You can also assign keyboard shortcuts in Mac Systems Settings.

Here is the link: DEVONtechnologies | Download

2 Likes

TextExpander is very easy to use and multiplatform with syncs.

Late on the party, but if 2 keyboard strokes are acceptable, then have a look at Gary Rosenzweigs free ClipTools

Paste Date, Paste Time

When you use Paste Date or Paste Time, the current time is pasted at the text cursor. The format for each of these is set in the Settings. The format matches Unicode date standards.

1 Like