@@ -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,95 @@ 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.5 or later** .
101
+
102
+ ### Example
103
+
104
+ The following example shows output values for the epoch time functions.
105
+
106
+ ``` bicep
107
+ param convertToEpoch int = dateTimeToEpoch(dateTimeAdd(utcNow(), 'P1Y'))
108
+
109
+ var convertToDatetime = dateTimeFromEpoch(convertToEpoch)
110
+
111
+ output epochValue int = convertToEpoch
112
+ output datetimeValue string = convertToDatetime
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
+
123
+ ## dateTimeToEpoch
124
+
125
+ ` dateTimeToEpoch(dateTime) `
126
+
127
+ Converts an ISO 8601 datetime string to an epoch time integer value.
128
+
129
+ Namespace: [ sys] ( bicep-functions.md#namespaces-for-functions ) .
130
+
131
+ ### Parameters
132
+
133
+ | Parameter | Required | Type | Description |
134
+ | :--- | :--- | :--- | :--- |
135
+ | dateTime | Yes | string | The datetime string to convert to an epoch time. |
136
+
137
+ ### Return value
138
+
139
+ An integer that represents the number of seconds from midnight on January 1, 1970.
140
+
141
+ ### Remarks
142
+
143
+ This function requires ** Bicep version 0.5.5 or later** .
144
+
145
+ ### Examples
146
+
147
+ The following example shows output values for the epoch time functions.
148
+
149
+ ``` bicep
150
+ param convertToEpoch int = dateTimeToEpoch(dateTimeAdd(utcNow(), 'P1Y'))
151
+
152
+ var convertToDatetime = dateTimeFromEpoch(convertToEpoch)
153
+
154
+ output epochValue int = convertToEpoch
155
+ output datetimeValue string = convertToDatetime
156
+ ```
157
+
158
+ The output is:
159
+
160
+ | Name | Type | Value |
161
+ | ---- | ---- | ----- |
162
+ | datetimeValue | String | 2023-05-02T15:16:13Z |
163
+ | epochValue | Int | 1683040573 |
164
+
165
+ The next example uses the epoch time value to set the expiration for a key in a key vault.
166
+
167
+ :::code language="bicep" source="~ /quickstart-templates/quickstarts/microsoft.storage/storage-blob-encryption-with-cmk/main.bicep":::
168
+
80
169
## utcNow
81
170
82
171
` utcNow(format) `
0 commit comments