# Datetime with T

**URL:** <https://forum.inductiveautomation.com/t/datetime-with-t/77321>\
**Category:** Ignition\
**Created:** [August 3, 2023, 12:14am UTC](https://forum.inductiveautomation.com/t/datetime-with-t/77321 "2023-08-03T00:14:52Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Babla\_Bogam](https://avatars.discourse-cdn.com/v4/letter/b/ecb155/32.png) [@Babla\_Bogam](https://forum.inductiveautomation.com/u/Babla_Bogam)\
**Post date:** [August 3, 2023, 12:14am UTC](https://forum.inductiveautomation.com/t/datetime-with-t/77321/1 "2023-08-03T00:14:52Z")

</div>

I am sending an API request to an external app. The API is returning an object with a date property that is a string in the format for example - 2023-08-02T23:05:52.187  
I am not able to convert that datetime to a local date time unless I use some string manipulation like separate by the letter T, break them into characters and build the date and time. I was wondering if there is a standard function in ignition that I can use to convert the above formatted date string (with T in it) to a local date time. Thank you

---

<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:** [August 3, 2023, 12:16am UTC](https://forum.inductiveautomation.com/t/datetime-with-t/77321/2 "2023-08-03T00:16:50Z")

</div>

I'd imagine some variation of the format string provided to `system.date.parse` would get you there.

[https://docs.inductiveautomation.com/display/DOC81/system.date.parse](https://docs.inductiveautomation.com/display/DOC81/system.date.parse)

---

<div class="post-metadata">

**Author:** ![Babla\_Bogam](https://avatars.discourse-cdn.com/v4/letter/b/ecb155/32.png) [@Babla\_Bogam](https://forum.inductiveautomation.com/u/Babla_Bogam)\
**Post date:** [August 3, 2023, 12:30am UTC](https://forum.inductiveautomation.com/t/datetime-with-t/77321/3 "2023-08-03T00:30:12Z")

</div>

so far I tried these options. in the script console. Only 1 option without time worked.

datetime\_with\_t = '2023-08-02T23:05:52.187'  
system.date.parse(datetime\_with\_t, 'yyyy-mm-dd"T"hh:mm:ssZ') - Gives illegalargumentexception for the letter T  
system.date.parse(datetime\_with\_t, 'yyyy-mm-dd-hh:mm:ssZ') - java.text.ParseException: Unparseable date: "2023-08-02T23:05:52.187"  
system.date.parse(datetime\_with\_t,yyyy-mm-dd hh:mm:ssZ) - java.text.ParseException: Unparseable date: "2023-08-02T23:05:52.187"  
system.date.parse(datetime\_with\_t,yyyy-MM-dd'T'00:00:00Z) - java.text.ParseException: java.text.ParseException: Unparseable date: "2023-08-02T23:05:52.187"  
system.date.parse(datetime\_with\_t,yyyy-MM-dd hh:mm:ss) - java.text.ParseException: java.text.ParseException: Unparseable date: "2023-08-02T23:05:52.187"  
system.date.parse(datetime\_with\_t,yyyy-MM-dd) - Result = Wed Aug 02 00:00:00 EDT 2023. success but no time. I need time as well.

---

<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:** [August 3, 2023, 12:35am UTC](https://forum.inductiveautomation.com/t/datetime-with-t/77321/4 "2023-08-03T00:35:22Z")

</div>

Try this:

```auto
datetime_with_t = '2023-08-02T23:05:52.187'

system.date.parse(datetime_with_t, "yyyy-MM-dd'T'HH:mm:ss.SSS")

```

shame on your API for not indicating UTC or timezone...

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 3, 2023, 12:36am UTC](https://forum.inductiveautomation.com/t/datetime-with-t/77321/5 "2023-08-03T00:36:08Z")

</div>

Grrr. Somebody types too fast.

---

<div class="post-metadata">

**Author:** ![Babla\_Bogam](https://avatars.discourse-cdn.com/v4/letter/b/ecb155/32.png) [@Babla\_Bogam](https://forum.inductiveautomation.com/u/Babla_Bogam)\
**Post date:** [August 3, 2023, 12:37am UTC](https://forum.inductiveautomation.com/t/datetime-with-t/77321/6 "2023-08-03T00:37:57Z")

</div>

Thank you so much. I was almost there. LOL

---

<div class="post-metadata">

**Author:** ![Kevin.Collins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.collins/32/13497_2.png) [@Kevin.Collins](https://forum.inductiveautomation.com/u/Kevin.Collins)\
**Post date:** [August 3, 2023, 12:38am UTC](https://forum.inductiveautomation.com/t/datetime-with-t/77321/7 "2023-08-03T00:38:45Z")

</div>

For future reference, this is [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format, looks like `+00:00` offset is implied..

EDIT: should have a `Z` at the end if it is UTC, though

---

<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:** [August 3, 2023, 12:39am UTC](https://forum.inductiveautomation.com/t/datetime-with-t/77321/8 "2023-08-03T00:39:46Z")

</div>

Yeah, but when returned by an API call... whose local does it use?

---

<div class="post-metadata">

**Author:** ![Kevin.Collins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.collins/32/13497_2.png) [@Kevin.Collins](https://forum.inductiveautomation.com/u/Kevin.Collins)\
**Post date:** [August 3, 2023, 12:40am UTC](https://forum.inductiveautomation.com/t/datetime-with-t/77321/9 "2023-08-03T00:40:43Z")

</div>

My take would be that it is UTC if TZ is omitted from the string. Though, per my edit above, should have a `Z` on the end in that case.

---

<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:** [August 3, 2023, 12:41am UTC](https://forum.inductiveautomation.com/t/datetime-with-t/77321/10 "2023-08-03T00:41:34Z")

</div>

Yeah, needs the Z. Unspecified/unqualified means local time, and is ambiguous. Stupid for an API.

---

<div class="post-metadata">

**Author:** ![Kevin.Collins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.collins/32/13497_2.png) [@Kevin.Collins](https://forum.inductiveautomation.com/u/Kevin.Collins)\
**Post date:** [August 3, 2023, 12:44am UTC](https://forum.inductiveautomation.com/t/datetime-with-t/77321/11 "2023-08-03T00:44:05Z")

</div>

> [@Kevin.Herron](#):
>
> Unspecified/unqualified means local time

Ahhh, I actually didn't know that.. String-based date/time representations are evil unless fully-qualified. 😃

---

<div class="post-metadata">

**Author:** ![Babla\_Bogam](https://avatars.discourse-cdn.com/v4/letter/b/ecb155/32.png) [@Babla\_Bogam](https://forum.inductiveautomation.com/u/Babla_Bogam)\
**Post date:** [August 3, 2023, 12:53am UTC](https://forum.inductiveautomation.com/t/datetime-with-t/77321/12 "2023-08-03T00:53:42Z")

</div>

my bad. The API vendor did mention as UTC in the documentation. I missed it. Thanks

---

<div class="post-metadata">

**Author:** ![Tim\_Carlton](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tim_carlton/32/52835_2.png) [@Tim\_Carlton](https://forum.inductiveautomation.com/u/Tim_Carlton)\
**Post date:** [August 3, 2023, 2:05pm UTC](https://forum.inductiveautomation.com/t/datetime-with-t/77321/13 "2023-08-03T14:05:32Z")

</div>

Vendor's bad. They **almost** followed the international standard but failed at the last character.
