Convert a datetime value (not timestamp) to UTC


I know that there are tons of topics on this subject, but the only ones that I found didn't work for me.\

I have a date field with a date and time that has to be converted in Logstash to the UTC value.

I tried lots of things, like the snippet below, but didn't work:
date {
match => ["record_date", "YYYY-MM-dd'T'HH:mm:ss.SSSSSSZ"]
timezone => "UTC"
#target => "record_date"

The output from that (with or without the target), has the same date time value as it was provided. How can I change the time to the equivalent UTC time?


timezone should be set to the timezone that the datetime is currently in, not the one you want to be changed to. That configuration tells logstash the datetime is already in UTC, so it will not be changed.

1 Like

Thanks for the reply. The problem is that the data is coming from JMS and the date was supposed to be persisted in UTC (requirement). The timestamp is actually in UTC, but not one of the incoming dates, so I have to convert to UTC in the record, before the elasticsearch output.

@Badger, after reading your post again, I figured out. I just set the date to my timezone, and everything now works as expected. Thanks a lot!!!

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