Using Azure Logic Apps within your environment and wanting to get the current date and time within the Logic App? In this blog post I will show how you can do this with using the function utcNow()
What is utcnow()
?
utcNow()
, as I mentioned above, is a function in Azure Logic Apps. It is used to return the current date and time in Coordinated Universal Time (UTC). This function is certainly useful to know. It is part of your LogicApp workflow which may require specific timestamps. For instance, if you’re saving files to Blob storage, you can easily append the current UTC time to your filenames, ensuring they’re unique and properly time-stamped.
Variations of utcnow()
There is many variations of how you can use utcnow()
– lets look at a few below to get you started:
utcNow()
– Returns the current date and time in UTC in the default format, e.g., “2024-07-03T21:34:56.789”.utcNow('yyyy-MM-dd')
– Returns just the current date in UTC, e.g., “2024-07-03”.utcNow('yyyy-MM-ddTHH:mm:ss')
– Returns the current date and time in UTC with a specific format, e.g., “2024-07-03T21:34:56”.utcNow('HH:mm:ss')
– Returns just the current time in UTC, e.g., “21:34:56”utcNow('yyyy-MM')
– Returns the current year and month in UTC, e.g., “2024-07”.
Example of using utcnow()
within a Logic App Workflow
See below, example usage – I am creating a blob as part of the workflow, with blobname I am appending the date in format:
Reviewing the blob storage account, we can see the successful blob created with associated timestamp
Some other example use cases
The list would be huge with what you can do, but some examples to consider:
- Time-based conditions: Trigger activites based on the current date and time
- Logging: Add timestamps to logs for better traceability
- Data Processing: Like the example I showed, append timestamps to files or records
The utcNow()
function in Azure Logic Apps is a simple yet powerful function to get the current date and time in a Logic App workflow. Thank you for reading – I hope you found this post helpful!