how to split array as per fixed length, and ionic two dates differences in min,seconds,hours


this.forsasi -->array
var perChunk = 5 // items per chunk
var inputArray = this.forsasi;
this.result = inputArray.reduce((resultArray, item, index) => {
const chunkIndex = Math.floor(index/perChunk);
if(!resultArray[chunkIndex]) {
resultArray[chunkIndex] = [] // start a new chunk
}
resultArray[chunkIndex].push(item);
return resultArray
}, [])
console.log(this.result);





this.d1 = JSON.parse(localStorage.getItem("starttime"));
var d2 = new Date(this.d1);
console.log(d2)
var date1 = new Date();
var Str1 =
("00" + (date1.getMonth() + 1)).slice(-2)
+ "/" + ("00" + date1.getDate()).slice(-2)
+ "/" + date1.getFullYear() + " "
+ ("00" + date1.getHours()).slice(-2) + ":"
+ ("00" + date1.getMinutes()).slice(-2)
+ ":" + ("00" + date1.getSeconds()).slice(-2);
console.log(Str1);
var d3 = new Date(Str1);
console.log(d3.getTime(), "d3.getTime()");
var diff1 = (d3.getTime() - d2.getTime()) / 1000; //seconds
console.log(diff1);
// diff1 /= 60; //mintues
//by 1000×60×60 convert to hour




Comments

Popular posts from this blog

push multiple data in array(select and disselect items in array)

how to active side menu in ionic3

how to add accordian to ionic project