Skip to Content
Sindre Sorhus
Back to Actions

Updated

How to Get a Unix Timestamp in Shortcuts on iPhone and Mac

By Sindre Sorhus, who makes the Actions app

With Actions

  1. Install Actions, and open it once.
  2. In your shortcut, add the “Convert Date to Unix Timestamp” action of Actions.
  3. In the date field, write “current date” for the time of now, or choose a date variable of the shortcut.
  4. Use its result, “Unix Timestamp”, in the next action, like in the request to a web API.

The result is in seconds. For milliseconds, which JavaScript uses, expand the action, and turn on “Use Milliseconds”.

To read a timestamp, like one from a web API, add the “Convert Unix Timestamp to Date” action, and give it the number. For a timestamp in milliseconds, turn on “Is Milliseconds”. The result is a date that the other actions of Shortcuts can use, like “Format Date”.

Get Actions

Additional actions for the Shortcuts app

Download on the App Store

Free

Requires
macOS, iOS, or visionOS 26 or later
Updated
June 2026
US App Store rating
4.8/5 (709 ratings)

More about Actions

Without an app

iPhone and Mac: Add the “Get Time Between Dates” action, and set it to get the seconds between 1 January 1970 at 00:00 and the current date. Write the first date in UTC, or the result can be wrong by the hours of your time zone.

Mac only: Add the “Run Shell Script” action, and type date +%s.

The built-in ways are fine for the timestamp of now, but the time zone of the first date is easy to get wrong. The actions of Actions convert in the two directions, and do not depend on your time zone.