我需要保存以这种方式格式化的日期“2015-03-25T12:00:00Z”,并且还会以dd-MM-yyyy或MM-dd-yyyy的格式显示日期,具体取决于用户的位置。 我有另一个问题我希望显示一个文本“过期”而不是日期过期的日期。但是,我正在显示我希望找到解决方案的日期代码。
$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;
}
这是它的观点:
<i class="icon--big fa fa-clock-o cursor-pointer" aria-hidden="true" title="{{ getBannerScheduledTitle(banner) }}" ng-class="{'expiredRed' : banner.expired}">