How to create a time log with timers in Power Apps / Power Platform
Creating a time log with timers in Power Apps / Power Platform lets you record when a task starts and ends, automatically calculate the duration and store the history for analysis. This feature is useful for monitoring productivity, project time or maintenance tasks.
Prerequisites
- Account with access to Power Apps and a Power Platform environment.
- A SharePoint list or a table in Dataverse to store records (fields: Title, StartTime, EndTime, DurationMinutes).
- Basic knowledge of Canvas Apps: galleries, forms and simple formulas.
Step 1: Create the data source
Create a list in SharePoint called TimeLogs (or use Dataverse). Add the columns:
- Title (Single line of text)
- StartTime (Date and Time)
- EndTime (Date and Time)
- DurationMinutes (Number)
This provides the schema to store each time entry.
Step 2: Create a Canvas App and connect the source
In Power Apps create a Canvas App (tablet or phone). In Data, add the connection to the TimeLogs SharePoint list (or the Dataverse table).
Step 3: Basic interface with gallery and detail
Add a Gallery bound to TimeLogs to list entries. Add an EditForm to show/edit a selected record.
// Example properties
Gallery.Items = TimeLogs
// Button for new record
NewButton.OnSelect = NewForm(EditForm1); Navigate(EditScreen, ScreenTransition.None)
// When selecting an item
Gallery.OnSelect = Select(Parent); EditForm1.Item = Gallery.Selected
Step 4: Add Start/Stop buttons with a local timer
We will use variables to control state and a Timer component to measure seconds. Insert a Timer (invisible if you prefer) and two buttons: Start and Stop.
// OnVisible of the initial screen
OnVisible = Set(varTimerRunning, false); Set(varCurrentRecord, Blank());
// Configure Timer1
Timer1.Duration = 1000 // 1 second
Timer1.Repeat = true
Timer1.AutoStart = varTimerRunning
Timer1.OnTimerEnd = Set(varSecondsCount, varSecondsCount + 1)
// StartButton.OnSelect
StartButton.OnSelect = Set(varStartTime, Now()); Set(varSecondsCount, 0); Set(varTimerRunning, true);
// StopButton.OnSelect
StopButton.OnSelect = Set(varEndTime, Now()); Set(varTimerRunning, false);
Explanation: we use Now() to record timestamps and a Timer that increments a counter every second. varSecondsCount is optional but useful for real-time feedback.
Step 5: Calculate duration and save to the datasource
When pressing Stop, calculate the duration in minutes and create/update the record in TimeLogs with Patch or SubmitForm.
// StopButton.OnSelect (with Patch for SharePoint/Dataverse)
StopButton.OnSelect =
Set(varEndTime, Now());
Set(varTimerRunning, false);
// Calculate duration in minutes
Set(varDurationMinutes, Round(Value(DateDiff(varStartTime, varEndTime, Seconds) / 60), 2));
// Save with Patch (example SharePoint/Dataverse)
Patch(
TimeLogs,
Defaults(TimeLogs),
{
Title: "Registo " & Text(Now(), "[$-en-US]yyyy-mm-dd HH:MM:SS"),
StartTime: varStartTime,
EndTime: varEndTime,
DurationMinutes: varDurationMinutes
}
);
// Clear variables for the next cycle
Set(varStartTime, Blank()); Set(varEndTime, Blank()); Set(varDurationMinutes, Blank()); Set(varSecondsCount, 0);
If you prefer a form, populate the form fields and call SubmitForm(EditForm1) instead of Patch.
Step 6: Show real-time feedback
Add labels to display StartTime, EndTime and a formatted counter while the timer is running.
// LabelStart.Text
LabelStart.Text = If(varStartTime, Text(varStartTime, "dd/mm/yyyy HH:MM:ss"), "Not started")
// LabelElapsed.Text
LabelElapsed.Text = If(varTimerRunning, Text(varSecondsCount, "[$-en-US]0") & " s", "0 s")
This gives the user immediate visibility of elapsed time.
Verify the result
Test like this: click Start — see the counter increase and StartTime fill; click Stop — confirm that EndTime appears and that a new item was created in the TimeLogs list with the correct DurationMinutes. Also verify in SharePoint/Dataverse the StartTime, EndTime and DurationMinutes fields.
Conclusion
You now have a working time log in Power Apps / Power Platform that marks start/end, calculates duration and saves to SharePoint or Dataverse. Next steps include adding user authentication (associate records to the current User), handling interruptions (pause/resume) and creating reports in Power BI. Tip: validate timezone and date formats to avoid discrepancies in international environments.