moment().fromNow() ignores UTC

I’ve seen multiple questions around this and this post did not clarify it for me.

I get ISO 8601 time from a query and want to display that result different depending on user config in a datagrid.

I have tried different methods both from documentation and stackoverflow, but none seems to give the expected result, which would be UTC-time fromNow(), but instead shows local time fromNow(). In console the values seems right until moment.fromNow()

                    // Changes value on item["StartTime"] based on user config before it pushed. 
                else {
                    let time = item["StartTime"] // Outputs ISO 8601

                    switch (true) {
                        case (userConfig.general.dateFormat == "From now" && userConfig.general.useLocal == false):
                            var utcDate = new Date(time).toUTCString();                              
                            utcDate = moment(utcDate).fromNow()
                            item["StartTime"] = utcDate


45 thoughts on “moment().fromNow() ignores UTC”