Fix Power Automate Excel Script Using the Wrong Date and Time
Question details
The user's Power Automate flow triggers an Office Script in an Excel file on OneDrive, but the script outputs an incorrect or unexpected date and time.

- Product
- Microsoft Excel, Power Automate
- Device & OS
- not provided
- Scenario
- Running an automated workflow where a Power Automate flow executes a custom Office Script on a cloud-hosted Excel spreadsheet.
- Observed behavior
- The generated date and time do not match the user's local timezone, typically defaulting to UTC because of cloud server processing.
Verify your local time zone requirements and check if your Power Automate flow is currently handling date and time values in Coordinated Universal Time (UTC).
Use the Convert Time Zone Action in Power Automate
Format and convert the UTC time to your local time zone directly within Power Automate before passing it to the Excel script.
Power Automate and OneDrive servers operate in UTC by default. To prevent the Office Script from logging the wrong time, you should handle the time conversion inside the flow.
Open your flow in Power Automate, click the '+' icon before your 'Run script' step, and search for 'Convert time zone'.
Set the 'Base time' to 'utcNow()'. Set the 'Source time zone' to '(UTC) Coordinated Universal Time' and the 'Destination time zone' to your local time zone.
Choose a 'Format string' that matches how you want the date to appear in Excel (e.g., 'yyyy-MM-ddTHH:mm:ss').
Update your 'Run script' action to accept this converted time output as an input parameter for your Excel Office Script, rather than letting the script generate the time.

Consult the Microsoft Power Automate Community
Seek specialized assistance for complex Power Automate flows and Office Script troubleshooting.
Need a Simpler Way to Manage Spreadsheets? Try WPS Office
If troubleshooting complex cloud workflows, Power Automate scripts, and timezone errors is slowing you down, WPS Office provides a lightweight, highly compatible, and user-friendly alternative for your spreadsheet needs.
- 1. Download and Install: Get WPS Office for free from the official website and install it on your device.
- 2. Open Your Spreadsheet: Launch WPS Spreadsheets and seamlessly open your existing Microsoft Excel files.
- 3. Use Built-in Functions: Easily manage local dates and times using intuitive formulas like =TODAY() and =NOW() without complex scripting.

Frequently Asked Questions
Why does Power Automate always default to UTC for dates?
Power Automate is a global cloud service. Standardizing all date and time values to Coordinated Universal Time (UTC) prevents data conflicts and synchronization errors across different servers, regions, and integrated applications.
Can I format the date directly inside the Excel Office Script instead?
Yes, you can use TypeScript methods like `toLocaleString()` inside your Office Script to adjust the timezone. However, handling the conversion in Power Automate is generally recommended as it is more visually configurable and easier to maintain.
Does the OneDrive server location affect my Excel script's time?
Yes, cloud-hosted files run on regional servers. If a script requests the current system time without specifying a timezone, it will pull the time from the server's location or default to UTC, which often differs from your local PC time.




