我对我的应用程序使用AngularJS,日期对象是$ scope.ProductionDate。如何从当前时间减去AngularJS中的一些小时
从上午5:00 2017年2月21日(2月21日)到4:59 2017年2月22日(2月22日)
我想ProductionDate值是2017年2月21日。
P.S.这里2月21日只是一个例子。每日我在给定的时间要求相同的价值。
我可以知道如何得到它吗?
function Ctrl($scope)
{
$scope.ProductionDate = new Date();
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app ng-controller="Ctrl">
ProductionDate: {{ProductionDate | date:'yyyy-MM-dd'}}<br/>
</div>
? –
我的意思是从今天早上5:00到明天早晨4:59 AM我希望日期成为今天的日期 – Ranger
Moment.js(https://momentjs.com/)值得一看。我有JS或甚至是Angular的方法来做这件事,但是在计算和格式化日期时,没有什么比使用moment.js简单,特别是如果您的项目中可能还有其他需求时。 –