【发布时间】:2016-06-24 23:25:16
【问题描述】:
我无法使用 Angularfire 从 firebase 显示日期(存储为 Unix 时间戳整数)。
我有以下html:
<div class="form-group"">
<label for="message-followUp" class="control-label">Follow Up Date:</label>
<input type="date" id="message-followUp" ng-model="postToUpdate.followUp">
</div>
和以下控制器:
$scope.notePost = function (id) {
var firebaseObj = new Firebase("https://firebase_url/Records/" + id);
$scope.postToUpdate = $firebaseObject(firebaseObj);
};
在返回的数据中,我有一个名为“followUp”的键,其中包含 Unix 时间戳。显示 html 时出现以下错误:
错误:[ngModel:datefmt] 预期
1466773470397是一个日期
我希望我可以将 'postToUpdate.followUp' 包装在 new date() 中,但这不起作用
如何将 Unix 时间戳转换为正确的日期格式 (yyyy-MM-dd),以便在显示时不会出现错误?
谢谢
【问题讨论】:
-
使用
new Date会发生什么?
标签: angularjs firebase angularfire firebase-realtime-database