# Help me to convert String to TimeStamp

**URL:** <https://discuss.elastic.co/t/help-me-to-convert-string-to-timestamp/55155>\
**Category:** Logstash\
**Created:** [July 11, 2016, 6:04am UTC](https://discuss.elastic.co/t/help-me-to-convert-string-to-timestamp/55155 "2016-07-11T06:04:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrei\_Brajnicov](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@Andrei\_Brajnicov](https://discuss.elastic.co/u/Andrei_Brajnicov)\
**Post date:** [July 11, 2016, 6:04am UTC](https://discuss.elastic.co/t/help-me-to-convert-string-to-timestamp/55155/1 "2016-07-11T06:04:49Z")

</div>

Hello.  
I should convert my string field to the TImeStamp.

These is the initial string field:  
"Jul 11, 2016 08:56:03.758207000"

Now I'm converting it using the following rule:  
"date {  
match =\> ["Origin", "MMM dd, yyyy HH:mm:sssssssss"]  
target =\> "Origin"  
timezone =\> "Europe/Chisinau"  
}"

Unfortunately it works only when the date is higher than 9. For example, if I will receive this string "Jul 5, 2016 08:56:03.758207000", the date will not be parsed correctly.

So In I case of  
"Jul 11, 2016 08:56:03.758207000"  
I should use  
MMM dd, yyyy HH:mm:sssssssss  
and in case of  
"Jul 5, 2016 08:56:03.758207000"  
I should use  
MMM d, yyyy HH:mm:sssssssss

Can someone give me an advice, how I can combine this 2 mathes?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [July 11, 2016, 6:58am UTC](https://discuss.elastic.co/t/help-me-to-convert-string-to-timestamp/55155/2 "2016-07-11T06:58:40Z")

</div>

I don't think the "s" date pattern token supports more than micosecond resolution. Are the last three digits always zero? If so you can just include them in your date pattern. Otherwise you can use a mutate filter's gsub option to remove the last three digits.

---

<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:** [July 6, 2017, 4:48am UTC](https://discuss.elastic.co/t/help-me-to-convert-string-to-timestamp/55155/3 "2017-07-06T04:48:42Z")

</div>


