Time array in javascript Ember JS -
i want create array of system time following format
["4:01pm","4:06pm","4:11pm","4:16pm","4:21pm","4:26pm"]
assuming system current time 4:26pm
how can create in javascript getting current system time
var = 6, result = [], time = new date(); while (i--) { var hours = time.gethours(), minutes = time.getminutes(); result[i] = ((hours - 1) % 12 + 1) + ':' + (minutes < 10 ? '0' : '') + minutes + (hours < 12 ? 'am' : 'pm'); time = new date(time - 5 * 60 * 1000); } console.log(result); // ["8:59am", "9:04am", "9:09am", "9:14am", "9:19am", "9:24am"]
Comments
Post a Comment