# Formatting time since state change

**URL:** <https://community.icinga.com/t/formatting-time-since-state-change/566>\
**Category:** Icinga Web Modules\
**Tags:** icingaweb2\
**Created:** [March 11, 2019, 5:18pm UTC](https://community.icinga.com/t/formatting-time-since-state-change/566 "2019-03-11T17:18:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rafiwui](https://community.icinga.com/user_avatar/community.icinga.com/rafiwui/32/336_2.png) [@rafiwui](https://community.icinga.com/u/rafiwui)\
**Post date:** [March 11, 2019, 5:18pm UTC](https://community.icinga.com/t/formatting-time-since-state-change/566/1 "2019-03-11T17:18:38Z")

</div>

I am trying to retrieve the moment of state change of a service or host. This works well as far as I want it formatted the same way as the header of _monitoring/service/show…_ but I want the point in time.  
So not _since 5m_ but instead _2019-03-11 18:15_. I checked out the rendered HTML and there is indeed a title behind the header label which tells me this exact information but I was unable to find where it is generated.  
 ![image](https://community.icinga.com/uploads/default/original/1X/66121edaae26dcced5bbb86b6d69e790203f1d55.png)

Can someone help me telling me how to get this information?

---

<div class="post-metadata">

**Author:** ![nilmerg](https://community.icinga.com/user_avatar/community.icinga.com/nilmerg/32/277_2.png) [@nilmerg](https://community.icinga.com/u/nilmerg)\
**Post date:** [March 12, 2019, 6:34am UTC](https://community.icinga.com/t/formatting-time-since-state-change/566/2 "2019-03-12T06:34:56Z")

</div>

You are probably looking for this:

> <https://github.com/Icinga/icingaweb2/blob/master/library/Icinga/Web/View/helpers/format.php>

for example in any view script (phtml):

```php
$this->formatDateTime(...);

```

---

<div class="post-metadata">

**Author:** ![rafiwui](https://community.icinga.com/user_avatar/community.icinga.com/rafiwui/32/336_2.png) [@rafiwui](https://community.icinga.com/u/rafiwui)\
**Post date:** [March 12, 2019, 9:16am UTC](https://community.icinga.com/t/formatting-time-since-state-change/566/3 "2019-03-12T09:16:52Z")

</div>

Thanks. That was exactly what I was looking for.
