Converting local UK dates in to UTC ISO formats

Hi

I am looking to take a local UK format DATETIME and convert it to an ISO UTC format

Currently I am parsing the date using a substring() in to LocaleDateTime.parse($inputStrings) to create a snaplocaledate value

When I try to parse the value out as a $snapLocalDateTime.toLocaleDateTimeString({“timeZone”:“UTC”, “format”:“yyyy-MM-ddTHH:mm:ssZ”})

I just get an error

Expression

$snapLocalOccurredAt.toLocaleDateTimeString({"timeZone":"UTC", "format":"yyyy-MM-dd HH:mm:ss"})

[
{
failure:
"Unknown method: toLocaleDateTimeString"
value:
"Please check expression syntax"
reason:
"Please check expression syntax"
sub-expression:
{
0: $snapLocalOccurredAt:
[
{
_snaptype_localdatetime:
"2021-10-18T07:20:52.000"
}
]
1: {"timeZone":"UTC", "format":"yyyy-MM-dd HH:mm:ss"}:
[
]
2: ({"timeZone":"UTC", "format":"yyyy-MM-dd HH:mm:ss"}):
[
[
{
timeZone:
"UTC"
format:
"yyyy-MM-dd HH:mm:ss"
}
]
]
}
}
]

Any help would be great

Using a GroundPlex in UK.

Hi @swampyedwards,

The incoming dates are in LocalDateTime format, so you need to parse them in DateTime UTC first, than add a custom format:

Date.parse($snapLocalOccurredAt.toString()).toLocaleDateTimeString({"format":"yyyy-MM-ddTHH:mm:ss"})

or

Date.parse($snapLocalOccurredAt,"yyyy-MM-dd'T'HH:mm:ss.SSS").toLocaleDateTimeString({"format":"yyyy-MM-ddTHH:mm:ss"})