I need to save a date formatted in this way "2015-03-25T12:00:00Z" and also show the date in the format dd-MM-yyyy or MM-dd-yyyy depending where the user it is. Another issue I have I would like to show a text "expired" instead of a date when a date is expired. However, I'm showing the date code I have hoping for a solution.
$scope.getItemScheduledTitle = function(item) {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
dd='0'+dd
}
if(mm<10) {
mm='0'+mm
}
today = mm+'/'+dd+'/'+yyyy;
var title = "";
if (item.from && item.to == null)
title += "from " + item.from + " to " + " ... ";
if (item.to && item.from == null)
title += "from " + today + " to " + item.to;
if (banner.to && banner.from)
title += "from " + banner.from + " to " + banner.to;
if (item.expired === true)
title += "Expired";
return title;
}
this the view of it:
<i class="icon--big fa fa-clock-o cursor-pointer" aria-hidden="true" title="{{ getBannerScheduledTitle(banner) }}" ng-class="{'expiredRed' : banner.expired}">