简体   繁体   English

将日期从一种格式转换为另一种格式-AngularJS

[英]Convert date from one format to another - AngularJS

How do I convert date from mm-dd-yyyy to mm/dd/yyyy in AngularJS. 如何在AngularJS中将日期从mm-dd-yyyy转换为mm / dd / yyyy。 Here is the plunker http://plnkr.co/edit/uoeuuHD8GOkPxj5LOlE5?p=preview 这是the人http://plnkr.co/edit/uoeuuHD8GOkPxj5LOlE5?p=preview

$scope.date = '07-28-2016';

{{ data | {{数据| date:'filter'}} //should return 07/28/2016 date:'filter'}} //应返回07/28/2016

First, start with an actual Date instance 首先,从实际的Date实例开始

$scope.date = new Date('2016-07-28'); // ISO 8601 date formats are less ambiguous

then use the date filter, ie 然后使用date过滤器,即

{{ date | date: 'MM/dd/yyyy' }}

http://plnkr.co/edit/ay2DDwzxQTiBx34bEO5d?p=preview http://plnkr.co/edit/ay2DDwzxQTiBx34bEO5d?p=preview

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 JavaScript 中将日期从一种格式转换为另一种格式 - Convert Date from one format to another format in JavaScript 将日期从一种给定格式转换为另一种格式 - converting date from one given format to another 如何将json从一种格式转换为另一种格式? - How to convert json from one format to another? 在momentjs中将日期从一个时区转换为另一个时区 - Convert date from one timezone to another in momentjs 将 JS 中的日期从一个时区转换为另一个时区 - Convert date in JS from one timezone to another 从一种日期格式转换为另一种格式会给出无效的日期 - Convert From One date format to other gives invalid date AngularJS将json格式转换为另一种json格式 - Convert json format to another json format by AngularJS 如何将 javascript 对象数组从一种格式转换为另一种格式? - How to convert a javascript array of Objects from one format to another format? 如何将一种格式的日期字符串转换为另一种格式的字符串(具有时区偏移量的字符串)? - How to convert a date string in one format to a string in another format (one with a timezone offset)? 在JavaScript中,如何将日期时间值从一种格式转换为另一种格式? - In JavaScript, How to Convert a date time value from one format to the other?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM