# Define time format as date prompt error

**URL:** <https://discuss.elastic.co/t/define-time-format-as-date-prompt-error/172050>\
**Category:** Logstash\
**Created:** [March 13, 2019, 3:12am UTC](https://discuss.elastic.co/t/define-time-format-as-date-prompt-error/172050 "2019-03-13T03:12:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![shenshensinian](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@shenshensinian](https://discuss.elastic.co/u/shenshensinian)\
**Post date:** [March 13, 2019, 3:12am UTC](https://discuss.elastic.co/t/define-time-format-as-date-prompt-error/172050/1 "2019-03-13T03:12:48Z")

</div>

Error message：failed to parse field [timestamp] of type [date]

Time sample format：

mar 13 10:36:03  
mar 13 2019 10:36:03  
2019-03-13 11:11:11

I want to be able to convert different date formats into yyyy-MM-dd hh:mm:ss

---

<div class="post-metadata">

**Author:** ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)\
**Post date:** [March 14, 2019, 12:00am UTC](https://discuss.elastic.co/t/define-time-format-as-date-prompt-error/172050/2 "2019-03-14T00:00:13Z")

</div>

You can use the [Date Filter Plugin](https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html) to parse any number of formats into a Time object, which serialises to a ISO8601-compatible representation.

It's not clear to me exactly what format strings to recommend, because it depends on whether your inputs zero-pad the day-of-month or hour-of-day fields; for example, the first input you give could be any of:

- mar 13 10:36:03
  - `MMM d H:mm:ss` (minimal day-of-month; minimal hour-of-day)
  - `MMM d HH:mm:ss` (minimal day-of-month; zero-padded two-digit hour-of-day)
  - `MMM dd H:mm:ss` (zero-padded two-digit day-of-month; minimal hour-of-day)
  - `MMM dd HH:mm:ss` (zero-padded two-digit day-of-month; zero-padded two-digit hour-of-day)

I would advise using the above-linked docs to define appropriate format strings.

---

<div class="post-metadata">

**Author:** ![shenshensinian](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@shenshensinian](https://discuss.elastic.co/u/shenshensinian)\
**Post date:** [March 14, 2019, 1:02am UTC](https://discuss.elastic.co/t/define-time-format-as-date-prompt-error/172050/3 "2019-03-14T01:02:58Z")

</div>

I want to know how to convert multiple formats into one format.

---

<div class="post-metadata">

**Author:** ![shenshensinian](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@shenshensinian](https://discuss.elastic.co/u/shenshensinian)\
**Post date:** [March 14, 2019, 2:36am UTC](https://discuss.elastic.co/t/define-time-format-as-date-prompt-error/172050/4 "2019-03-14T02:36:50Z")

</div>

> [@yaauie](#):
>
> You can use the [Date Filter Plugin](https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html) to parse any number of formats into a Time object, which serialises to a ISO8601-compatible representation.
> 
> It's not clear to me exactly what format strings to recommend, because it depends on whether your inputs zero-pad the day-of-month or hour-of-day fields; for example, the first input you give could be any of:
> 
> - mar 13 10:36:03
> - `MMM d H:mm:ss` (minimal day-of-month; minimal hour-of-day)
> - `MMM d HH:mm:ss` (minimal day-of-month; zero-padded two-digit hour-of-day)
> - `MMM dd H:mm:ss` (zero-padded two-digit day-of-month; minimal hour-of-day)
> - `MMM dd HH:mm:ss` (zero-padded two-digit day-of-month; zero-padded two-digit hour-of-day)
> 
> I would advise using the above-linked docs to define appropriate format strings.

[14/Mar/2017:06:57:12 +0800] How to convert this into "2017-11-20 12:00:00" in logstash

---

<div class="post-metadata">

**Author:** ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)\
**Post date:** [March 14, 2019, 8:17am UTC](https://discuss.elastic.co/t/define-time-format-as-date-prompt-error/172050/5 "2019-03-14T08:17:51Z")

</div>

Please read the linked documentation, try it for yourself, and come back with a description of what you tried, what you expected to happen, and what behaviour you observed if you are still having problems.

---

<div class="post-metadata">

**Author:** ![shenshensinian](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@shenshensinian](https://discuss.elastic.co/u/shenshensinian)\
**Post date:** [March 15, 2019, 1:06am UTC](https://discuss.elastic.co/t/define-time-format-as-date-prompt-error/172050/6 "2019-03-15T01:06:12Z")

</div>

After matching the timestamp with the target to the timestamp by matching, the time is automatically reduced by 8 hours.

---

<div class="post-metadata">

**Author:** ![shenshensinian](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@shenshensinian](https://discuss.elastic.co/u/shenshensinian)\
**Post date:** [March 15, 2019, 1:15am UTC](https://discuss.elastic.co/t/define-time-format-as-date-prompt-error/172050/7 "2019-03-15T01:15:38Z")

</div>

> [@yaauie](#):
>
> Please read the linked documentation, try it for yourself, and come back with a description of what you tried, what you expected to happen, and what behaviour you observed if you are still having problems.

Solved, thank you.

---

<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:** [April 12, 2019, 1:15am UTC](https://discuss.elastic.co/t/define-time-format-as-date-prompt-error/172050/8 "2019-04-12T01:15:40Z")

</div>

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