3

Import UTC DateTime from JSON / Rest-Request into Ninox local DateTime via Timestamp

We have developed an API-Connection between Ninox and Shopware for importing new orders from the webshop. Part of this development was the conversion of a returned UTC-DateTime into a Ninox-local-DateTime. 

Here is the Code:

"### Server sits in Germany / UTC+2 (DST) ###";
let dt := "2024-05-08T21:03:35.751+00:00"

let year := number(substring(dt, 0, 4));
let month := number(substring(dt, 5, 7));
let day := number(substring(dt, 8, 10));
let hour := number(substring(dt, 11, 13));
let minute := number(substring(dt, 14, 16));
let second := number(substring(dt, 17, 19));
let millisecond := number(substring(dt, 20, 23));
let orderDate := date(year, month, day)
let orderTime := time(hour, minute, second, millisecond)

"Original: " + dt  + "
Substrings: " + year + " " + month + " " + day + " " + hour + " " + minute + " " + second + " " + millisecond + "
Date: " + orderDate  + "
Time: " + orderTime  + "
Timestamp (localized): " + timestamp(orderDate + orderTime)

 

With the Result:

Original: 2024-05-08T21:03:35.751+00:00
Substrings: 2024 5 8 21 3 35 751
Date: 08.05.2024
Time: 21:03
Timestamp: 08.05.2024 23:03

Reply

null

Content aside

  • 3 Likes
  • 7 mths agoLast active
  • 56Views
  • 1 Following