0

Convert date+time UTC in text format to timestamp

I need help with the following timestamp (in text format) to a date and time (Mountain Time zone) fields:

2026-06-02 06:00:52.742 UTC

I tried with Ninox 4 but the timestamp instruction does not work:

 

let utc_ts := timestamp(utc_timestamp_text);

let utc_year := year(utc_ts);

let utc_month := month(utc_ts);

let utc_day := day(utc_ts);

let is_dst := if utc_month > 3 and utc_month < 11 then

                        true

            else

                        if utc_month = 3 then

                                    utc_day > 14 - weekday(date(utc_year, 3, 1))

                        else

                                    if utc_month = 11 then

                                                utc_day < 7 - weekday(date(utc_year, 11, 1))

                                    else

                                                false

                                    end

                        end

            end;

let offset_hours := if is_dst then -7 else -6 end;

datetime(utc_ts + timeinterval(offset_hours * 3600000))

 

In Ninox 4, it creates a new timestamp for Mountain time. However, when I try it in Ninox 3, it does not work at all.

1 reply

null
    • red_kite
    • 3 days ago
    • Reported - view

    Hi, Miriam. I think datetime and timestamp don't have a parameter in stringformat. These require the format number. But I don't know anything about ninox 4. Here is a small script as a workaround.

    let utcText := "2026-06-02 06:00:52.742 UTC";
    let firstSplitter := split(utcText, " ");
    let splitDateUTC := split(first(firstSplitter), "-");
    let splitTimeUTC := split(item(firstSplitter, 1), ":");
    let utcDatetime := datetime(number(first(splitDateUTC)), number(item(splitDateUTC, 1)), number(last(splitDateUTC)), number(first(splitTimeUTC)), number(item(splitTimeUTC, 1)), number(last(splitTimeUTC)));
    function DatesOfDaylightSavingTime(yr : number) do
        let march := range(datetime(yr, 3, 8, 3, 0), datetime(yr, 3, 16, 3, 0), 86400000)[weekday(this) = 6];
        let november := range(datetime(yr, 11, 1, 3, 0), datetime(yr, 11, 8, 3, 0), 86400000)[weekday(this) = 6];
        array(march, november)
    end;
    function MountainZone(utc : datetime) do
        let value := if utc < first(DatesOfDaylightSavingTime(year(utc))) or
                last(DatesOfDaylightSavingTime(year(utc))) >= utc then
                7 * 3600000
            else
                6 * 3600000
            end;
        utc + value
    end;
    MountainZone(utcDatetime)

Content aside

  • 3 days agoLast active
  • 1Replies
  • 30Views
  • 2 Following