正确格式化日期以便在firefox中显示
Properly formatting date for display in firefox
我有这样的日期
美元范围。Newd = '2015-08-11 12:36:33.649';
来自后端JSON。在我的UI中,我想显示11/08/2015。
我使用Date.parse($scope.newd)
转换,然后格式化。但这在FF中不起作用。我该怎么做呢?
为跨浏览器兼容性,
日期字符串用"-"转换为"/",去掉时间,
$scope.oldDate = '2015-08-11 12:36:33.649';
$scope.newD= $filter('date')(new Date($scope.oldDate.split(" ")[0].replace(/-/g,"/")), 'dd/MM/yyyy');
参考这个链接:http://dygraphs.com/date-formats.html
你可以像
$scope.oldDate = '2015-08-11 12:36:33.649';
$scope.newD= $filter('date')(new Date(parseInt($scope.oldDate.substr(6))), 'dd/MM/yyyy');
你必须在控制器中注入$filter
过滤器
在你的html中像这样使用日期过滤器
{{ date_expression | date : format : timezone}
阅读这里的文档
<标题> 例子下面是一个日期输入的示例,它在通过过滤器后显示。
<p>
<label>Select a date</label>
<input type="date" id="date" ng-model="datevalue" />
</p>
<p> {{ datevalue | date : 'dd/MM/yyyy'}} </p>
标题> Date.prototype.today = function () {
return ((this.getDate() < 10)?"0":"") + this.getDate() +"/"+(((this.getMonth()+1) < 10)?"0":"") + (this.getMonth()+1) +"/"+ this.getFullYear();
}
var newDate = new Date($scope.newd );
var date =newDate.today();
$scope.newd = newDate.today();
相关文章:
- 在firefox和chrome中的左侧显示iframe滚动条
- Firefox赢得了'不会显示我添加的jquery元素,但Chrome会显示
- Firefox-当不在输入控件上时隐藏焦点高亮显示
- HTML选择,在DOM中选择了正确的选项,但在firefox中显示了错误的项目
- Chrome和Firefox之间的Wordpress显示差异
- mozilla firefox上没有显示Facebook共享按钮
- iframe不仅在Firefox上显示正确
- 如果用户的浏览器早于以下版本,则显示一条消息:IE 10、Firefox 39、Chrome 39、Opera 8
- extjs在chrome中可以正常工作;不要在firefox或ie中显示任何内容
- 俄罗斯木偶与Firefox和Webkit的显示问题:与IE配合良好
- 在chrome上显示类似于关闭窗口时的firefox的警报消息.确认消息”;离开"或“;留在这个页面上&quo
- Firefox断开页面;不显示图像或CSS样式
- Chrome、Firefox转换“:"至“-"以及“_"分别显示在文件保存对话框中
- firefox中未显示Facebook注册
- html数据属性在firefox中使用javascript时没有按预期显示,但在chrome中显示正确
- Chrome 和 Firefox 显示的页码不同
- Firefox 显示的行为与视频“进度”事件不一致
- Firefox-显示来自扩展插件/插件的网络通知
- Firefox显示日期为NaN
- Firefox显示没有源的图像