@@ -4,7 +4,7 @@ description: Describes the functions to use in a Bicep file to work with dates.
4
4
author : mumian
5
5
ms.author : jgao
6
6
ms.topic : conceptual
7
- ms.date : 09/30/2021
7
+ ms.date : 05/02/2022
8
8
---
9
9
10
10
# Date functions for Bicep
@@ -77,6 +77,94 @@ resource scheduler 'Microsoft.Automation/automationAccounts/schedules@2015-10-31
77
77
}
78
78
```
79
79
80
+ ## dateTimeFromEpoch
81
+
82
+ ` dateTimeFromEpoch(epochTime) `
83
+
84
+ Converts an epoch time integer value to an ISO 8601 datetime.
85
+
86
+ Namespace: [ sys] ( bicep-functions.md#namespaces-for-functions ) .
87
+
88
+ ### Parameters
89
+
90
+ | Parameter | Required | Type | Description |
91
+ | :--- | :--- | :--- | :--- |
92
+ | epochTime | Yes | int | The epoch time to convert to a datetime string. |
93
+
94
+ ### Return value
95
+
96
+ An ISO 8601 datetime string.
97
+
98
+ ### Remarks
99
+
100
+ This function requires ** Bicep version 0.5.6 or later** .
101
+
102
+ ### Example
103
+
104
+ The following example shows output values for the epoch time functions.
105
+
106
+ ``` bicep
107
+ param convertedEpoch int = dateTimeToEpoch(dateTimeAdd(utcNow(), 'P1Y'))
108
+
109
+ var convertedDatetime = dateTimeFromEpoch(convertedEpoch)
110
+
111
+ output epochValue int = convertedEpoch
112
+ output datetimeValue string = convertedDatetime
113
+ ```
114
+
115
+ The output is:
116
+
117
+ | Name | Type | Value |
118
+ | ---- | ---- | ----- |
119
+ | datetimeValue | String | 2023-05-02T15:16:13Z |
120
+ | epochValue | Int | 1683040573 |
121
+
122
+ ## dateTimeToEpoch
123
+
124
+ ` dateTimeToEpoch(dateTime) `
125
+
126
+ Converts an ISO 8601 datetime string to an epoch time integer value.
127
+
128
+ Namespace: [ sys] ( bicep-functions.md#namespaces-for-functions ) .
129
+
130
+ ### Parameters
131
+
132
+ | Parameter | Required | Type | Description |
133
+ | :--- | :--- | :--- | :--- |
134
+ | dateTime | Yes | string | The datetime string to convert to an epoch time. |
135
+
136
+ ### Return value
137
+
138
+ An integer that represents the number of seconds from midnight on January 1, 1970.
139
+
140
+ ### Remarks
141
+
142
+ This function requires ** Bicep version 0.5.6 or later** .
143
+
144
+ ### Examples
145
+
146
+ The following example shows output values for the epoch time functions.
147
+
148
+ ``` bicep
149
+ param convertedEpoch int = dateTimeToEpoch(dateTimeAdd(utcNow(), 'P1Y'))
150
+
151
+ var convertedDatetime = dateTimeFromEpoch(convertedEpoch)
152
+
153
+ output epochValue int = convertedEpoch
154
+ output datetimeValue string = convertedDatetime
155
+ ```
156
+
157
+ The output is:
158
+
159
+ | Name | Type | Value |
160
+ | ---- | ---- | ----- |
161
+ | datetimeValue | String | 2023-05-02T15:16:13Z |
162
+ | epochValue | Int | 1683040573 |
163
+
164
+ The next example uses the epoch time value to set the expiration for a key in a key vault.
165
+
166
+ :::code language="bicep" source="~ /quickstart-templates/quickstarts/microsoft.storage/storage-blob-encryption-with-cmk/main.bicep":::
167
+
80
168
## utcNow
81
169
82
170
` utcNow(format) `
0 commit comments