我正在使用下面的代码从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?
也许像这样]
let time = militaryTime/100-12 + ":00";
?
您可以进一步转换检索列表中的项目值