# I can't record the current date from the log string in the @timestamp field

**URL:** <https://discuss.elastic.co/t/i-cant-record-the-current-date-from-the-log-string-in-the-timestamp-field/289201>\
**Category:** Logstash\
**Created:** [November 15, 2021, 1:31pm UTC](https://discuss.elastic.co/t/i-cant-record-the-current-date-from-the-log-string-in-the-timestamp-field/289201 "2021-11-15T13:31:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vanro/32/97132_2.png) [@vanro](https://discuss.elastic.co/u/vanro)\
**Post date:** [November 15, 2021, 1:31pm UTC](https://discuss.elastic.co/t/i-cant-record-the-current-date-from-the-log-string-in-the-timestamp-field/289201/1 "2021-11-15T13:31:44Z")

</div>

Hello, I can't record the current date from the log string in the @timestamp field and convert the time field from the string type to the date type. Can you tell me what I'm doing wrong? My configuration is shown below..

 ![photo_2021-11-15_17-23-05](https://us1.discourse-cdn.com/elastic/original/3X/d/c/dcbefa63423c86217b6ca7c48361be803514c256.jpeg)

```auto
if [type] == "bl" {
		grok {
			patterns_dir => ["/etc/logstash/patterns"]
			match => { "message" => "%{FIRESEC_BL_GENERAL}" }
		}
		date {
			match => ["time", "dd MMM yyyy hh:mm:ss.SSS"]
			target => "time"
		}
		date {
			match => ["time", "dd MMM yyyy hh:mm:ss.SSS"]
			target => "@timestamp"
		}
	}

```

My patterns:  
FIRESEC\_TIME %{MONTHDAY} %{MONTH} %{YEAR} %{TIME}  
FIRESEC\_BL\_GENERAL %{FIRESEC\_TIME:time} [(?\<module\_name\>(?:[^-]+|-(?:$|[^\d]))_)-(?\<module\_version\>[^]]_)][(?\<alert\_source\>[^]]_)] (?\<alert\_type\>[^]_) _(?\<alert\_message\>[^\n^.]_)

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [November 15, 2021, 2:15pm UTC](https://discuss.elastic.co/t/i-cant-record-the-current-date-from-the-log-string-in-the-timestamp-field/289201/2 "2021-11-15T14:15:27Z")

</div>

Try to change your date filter, use `HH` instead of `hh`.

Change it to: `"dd MMM yyyy HH:mm:ss.SSS"`.

Lowercase `h` is used when you have AM/PM time, it means _clockhour of halfday (1~12)_.

When you have the time with 24 hour format you need to use `HH`.

---

<div class="post-metadata">

**Author:** ![vanro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vanro/32/97132_2.png) [@vanro](https://discuss.elastic.co/u/vanro)\
**Post date:** [November 16, 2021, 1:29pm UTC](https://discuss.elastic.co/t/i-cant-record-the-current-date-from-the-log-string-in-the-timestamp-field/289201/3 "2021-11-16T13:29:30Z")

</div>

Thank you very much, it helped me ❤ ❤ ❤ ❤ ❤

---

<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:** [December 14, 2021, 1:30pm UTC](https://discuss.elastic.co/t/i-cant-record-the-current-date-from-the-log-string-in-the-timestamp-field/289201/4 "2021-12-14T13:30:31Z")

</div>

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