Hey, so in my application i’ve created a service for converting date into seconds / minutes / days / full dates,
This works nice in browsers and on android phones, but when i run it on an android device, all my dates get displayed as NaN(not a number) is there a fix for this?
This is my code:
.factory('displaydate',['$filter', function($filter) {
return function (date){
var maandarray = new Array('Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December');
var actiondate = new Date(date);
var today = new Date();
if(today.getDate() == actiondate.getDate()){
var hourssince = today.getHours() - actiondate.getHours()
var minutessince = today.getMinutes() - actiondate.getMinutes()
var secondssince = today.getSeconds() - actiondate.getSeconds()
if(hourssince > 0){
date = hourssince+'u';
}else if(minutessince > 0){
date = minutessince+'m';
}else{
date = secondssince+'s';
}
}else{
var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
var diffDays = Math.round(Math.abs((today.getTime() - actiondate.getTime())/(oneDay)));
if(diffDays > 28){
var identifier = actiondate.getMonth() - 1;
var month = maandarray[identifier];
date = $filter('date')(actiondate,"d ") + month + $filter('date')(actiondate," yy " + " HH:" + "mm");
}else{
date = diffDays+'d';
}
}
return date;
}
}]);