# Template Notification convert string to time grafana

**URL:** <https://community.grafana.com/t/template-notification-convert-string-to-time-grafana/144372>\
**Category:** Grafana\
**Tags:** alert-templating, alerting\
**Created:** [February 19, 2025, 11:51am UTC](https://community.grafana.com/t/template-notification-convert-string-to-time-grafana/144372 "2025-02-19T11:51:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![trm](https://avatars.discourse-cdn.com/v4/letter/t/b5ac83/32.png) [@trm](https://community.grafana.com/u/trm)\
**Post date:** [February 19, 2025, 11:51am UTC](https://community.grafana.com/t/template-notification-convert-string-to-time-grafana/144372/1 "2025-02-19T11:51:36Z")

</div>

I would like to convert a string to a timestamp in grafana notification alert.  
Example:  
[  
{  
“status”: “firing”,  
“annotations”: {  
“summary”: “Instance instance1 has been down for more than 5 minutes”  
},  
“labels”: {  
“timestamp”: “2025-02-19T03:15:48.219Z”,  
},  
“startsAt”: “2025-02-18T07:15:48.219Z”,  
“endsAt”: “2025-02-19T07:20:48.219Z”,  
“fingerprint”: “a5331f0d5a9d81d4”,  
“generatorURL”: “[http://grafana.com/alerting/grafana/cdeqmlhvflz40f/view](http://grafana.com/alerting/grafana/cdeqmlhvflz40f/view)”  
},  
]

According to documentation you can use “date” function to convert to a timestamp, but it does not work:  
{{- if (index . “HourDK”) }}

- HourDK: {{ index . “HourDK” | date “2024-01-01” }}  
{{- end }}

error:  
template: :10:37: executing “test\_markdown” at \<“2024-01-01”\>: wrong type for value; expected time.Time; got string
