# Format triggered\_time to local time zone in action

**URL:** <https://discuss.elastic.co/t/format-triggered-time-to-local-time-zone-in-action/144299>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [August 14, 2018, 8:37am UTC](https://discuss.elastic.co/t/format-triggered-time-to-local-time-zone-in-action/144299 "2018-08-14T08:37:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakn](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@jakn](https://discuss.elastic.co/u/jakn)\
**Post date:** [August 14, 2018, 8:37am UTC](https://discuss.elastic.co/t/format-triggered-time-to-local-time-zone-in-action/144299/1 "2018-08-14T08:37:24Z")

</div>

I want to include triggered\_time in local time zone in my actions (log, email, ...).

{{ctx.trigger.triggered\_time}} shows triggered\_time in UTC, but how should the example below be modified to also include triggered\_time for time zone 'Europe/Copenhagen'?

```
PUT _xpack/watcher/watch/triggered_time
{
  "trigger" : { "schedule" : { "interval" : "10s" } },
  "input" : {
"search" : {
  "request" : {
    "indices" : ["logs"],
    "body" : {
      "query" : {
        "match" : { "message": "error" }
      }
    }
  }
}
  },
  "actions" : {
"log_error" : {
  "logging" : {
    "text" : "Triggered time (UTC):{{ctx.trigger.triggered_time}} - Triggered time (Europe/Copenhagen): ????"
  }
}
  }
}
```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 14, 2018, 9:12am UTC](https://discuss.elastic.co/t/format-triggered-time-to-local-time-zone-in-action/144299/2 "2018-08-14T09:12:16Z")

</div>

try this (note that this example fully overwrites the payload, you may want to add this to the additional payload instead)

```auto
POST _xpack/watcher/watch/_execute
{
  "watch": {
    "trigger": {
      "schedule": {
        "interval": "10s"
      }
    },
    "input": {
      "simple": {}
    },
    "actions": {
      "log_error": {
        "transform": {
          "script": """
return ['date': Instant.ofEpochMilli(ctx.trigger.triggered_time.getMillis()).atZone(ZoneId.of("Europe/Copenhagen"))]"""
        },
        "logging": {
          "text": "Triggered time (UTC):{{ctx.trigger.triggered_time}} - Triggered time (Europe/Copenhagen): {{ctx.payload.date}}"
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![jakn](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@jakn](https://discuss.elastic.co/u/jakn)\
**Post date:** [August 14, 2018, 11:07am UTC](https://discuss.elastic.co/t/format-triggered-time-to-local-time-zone-in-action/144299/3 "2018-08-14T11:07:47Z")

</div>

Thanks.

The converted timestamp is outputted as e.g.:

> 2018-08-16T10:13:58.698+02:00[Europe/Copenhagen]

Is there any way to generate a string formatted like this instead?

> 2018-08-16 10:13:58 [Europe/Copenhagen]

Update 2018-09-17:  
Last question is answered here:  
`https://discuss.elastic.co/t/transform-datetime-to-string/148822`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 11, 2018, 11:07am UTC](https://discuss.elastic.co/t/format-triggered-time-to-local-time-zone-in-action/144299/4 "2018-09-11T11:07:48Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
