# System.date.parse not working properly

**URL:** <https://forum.inductiveautomation.com/t/system-date-parse-not-working-properly/77027>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [July 27, 2023, 5:10pm UTC](https://forum.inductiveautomation.com/t/system-date-parse-not-working-properly/77027 "2023-07-27T17:10:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andy\_Guias](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@Andy\_Guias](https://forum.inductiveautomation.com/u/Andy_Guias)\
**Post date:** [July 27, 2023, 5:10pm UTC](https://forum.inductiveautomation.com/t/system-date-parse-not-working-properly/77027/1 "2023-07-27T17:10:05Z")

</div>

I was testing this Scripting Function in the Script Console and I am getting some bad results.  
Does anyone have any idea about what I'm doing wrong here:

```auto
d1 = system.date.format(system.date.now(), "YYYY-MM-dd HH:mm:ss.SSS")
d1

d2 = system.date.parse(d1, "YYYY-MM-dd HH:mm:ss.SSS")
d2

```

Thank you!

 ![Script Console 1](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/c/5cba4ec8e788e01f1e34e1b938bd8e327161fd20.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 27, 2023, 5:20pm UTC](https://forum.inductiveautomation.com/t/system-date-parse-not-working-properly/77027/2 "2023-07-27T17:20:50Z")

</div>

What are you actually trying to accomplish?

You're just getting confused over the string representation.

`d1` is a String you've formatted a Date object into. You chose the format of that string.

`d2` is Date object you've parsed from `d1`, being displayed using the built-in `toString()` representation. The Date object displays itself differently than the format you parsed the original date into.

---

<div class="post-metadata">

**Author:** ![Andy\_Guias](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@Andy\_Guias](https://forum.inductiveautomation.com/u/Andy_Guias)\
**Post date:** [July 27, 2023, 5:22pm UTC](https://forum.inductiveautomation.com/t/system-date-parse-not-working-properly/77027/3 "2023-07-27T17:22:16Z")

</div>

The problem that I noticed is that the date value is different, the day and month, specifically.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 27, 2023, 5:24pm UTC](https://forum.inductiveautomation.com/t/system-date-parse-not-working-properly/77027/4 "2023-07-27T17:24:54Z")

</div>

Oh I see, hang on...

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 27, 2023, 5:28pm UTC](https://forum.inductiveautomation.com/t/system-date-parse-not-working-properly/77027/5 "2023-07-27T17:28:30Z")

</div>

Use lower-case 'y':

```auto
d1 = system.date.format(system.date.now(), "yyyy-MM-dd HH:mm:ss.SSS")
d1

d2 = system.date.parse(d1, "yyyy-MM-dd HH:mm:ss.SSS")
d2

```

upper-case 'Y' is for "week years", which is still not a thing I actually understand.

[https://docs.inductiveautomation.com/display/DOC81/Data+Type+Formatting+Reference](https://docs.inductiveautomation.com/display/DOC81/Data+Type+Formatting+Reference)  
[https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/SimpleDateFormat.html](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/SimpleDateFormat.html)

---

<div class="post-metadata">

**Author:** ![Andy\_Guias](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@Andy\_Guias](https://forum.inductiveautomation.com/u/Andy_Guias)\
**Post date:** [July 27, 2023, 5:29pm UTC](https://forum.inductiveautomation.com/t/system-date-parse-not-working-properly/77027/6 "2023-07-27T17:29:24Z")

</div>

Awesome, thank you!
