Vue中是否有一种方法可以将军事时间转换为标准时间

问题描述 投票:-2回答:2

我正在使用下面的代码从JSON API中获取军事时间。

mounted: function(){
    var currentDate = moment().format('YYYY-MM-DD');
    axios.get("https://mysiteurl.com/api/ordersseller=5e1f43c0c69e7&items.arrival="+currentDate)
     .then(response => (this.post = response.data.data));
},

data(){
    return{
      post: []
   }
}


// the time value that I receive through that API is 1500, 1600 and 1700 

这是显示上面时间的模板视图。

<div v-for="item in post.items" v-bind:key="item.arrival">
    {{item.arrivalTime}}
</div>

我如何将军事时间值转换为1500、1600和1700 标准时间,以便它们在]中打印为03:00 PM,04:00 PM和05:00 PM。 Vue.js

javascript vue.js momentjs bootstrap-vue
2个回答
0
投票

也许像这样]

let time = militaryTime/100-12 + ":00";


0
投票

您可以进一步转换检索列表中的项目值

© www.soinside.com 2019 - 2024. All rights reserved.