Skip to content

Get today's date and the current time

This article explains how to get today’s date and the current time.

Details of the “Get current date and time” action

Section titled “Details of the “Get current date and time” action”

The action used here is called “Get current date and time.”

The action has the following parameters.

Parameter Value
Retrieve Choose “Current date and time” (date and time) or “Current date only”
Time zone Choose whether to use the system time zone or specify a time zone
Variables produced The name of the variable that stores the retrieved datetime (default: CurrentDateTime)

action

If you choose “Current date only,” the time is stored as 0:00:00.

For the time zone, besides “System time zone,” you can choose “Windows time zone” (select from a list), “Custom input” (enter an offset from UTC or a Windows-format time zone name), or “Specific time zone” (enter a country/region; to be deprecated). Unless you have a particular need, “System time zone” should be fine.

As a sample, I prepared a flow that gets the date and time at the moment it runs and stores the hour and minute in separate variables.

Copy the following code and paste it into the Power Automate Desktop flow designer to add the actions.

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''HH''' Result=> CurrentHour
Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''mm''' Result=> CurrentMinute
  1. In “Search actions,” type “Get current date and time.”

  2. Set the parameters as follows.

    Parameter Value
    Retrieve Current date and time
    Time zone System time zone
    Variables produced CurrentDateTime
  3. When you run the flow, today’s date and the current time are stored in the variable.

The action fails with an error if the date and time can’t be retrieved for some reason.

Also, if you choose “Specific time zone” for the time zone, you can enter any country/region, and no error occurs before the run. However, if the country/region doesn’t exist, the action fails with an error at run time.

We recommend adding error handling with an “On block error” block.

The variable this action produces is of the Datetime type, so extracting or transforming its data takes a little ingenuity.

See the following pages for how to use it.