- 本地化日期格式化:
- ({{ today | date:'medium' }})Nov 24, 2015 2:19:24 PM
- ({{ today | date:'short' }})11/24/15 2:19 PM
- ({{ today | date:'fullDate' }})Tuesday, November 24, 2015
- ({{ today | date:'longDate' }})November 24, 2015
- ({{ today | date:'mediumDate' }})Nov 24, 2015
- ({{ today | date:'shortDate' }})11/24/15
- ({{ today | date:'mediumTime' }})2:19:24 PM
- ({{ today | date:'shortTime' }})2:19 PM
- 年份格式化:
- 四位年份:({{ today | date:'yyyy' }})2015
- 两位年份:({{ today | date:'yy' }})15
- 一位年份:({{ today | date:'y' }})2015
- 月份格式化:
- 英文月份:({{ today | date:'MMMM' }})November
- 英文月份简写:({{ today | date:'MMM' }})Nov
- 两位数字月份:({{ today | date:'MM' }})11
- 一年中的第几个月份:({{ today | date:'M' }})11
- 日期格式化:
- 数字日期:({{ today | date:'dd' }})24
- 一个月中的第几天:({{ today | date:'d' }})24
- 英文星期:({{ today | date:'EEEE' }})Tuesday
- 英文星期简写:({{ today | date:'EEE' }})Tue
- 小时格式化:
- 24小时制数字小时:({{ today | date:'HH' }})14
- 一天中的第几个小时:({{ today | date:'H' }})14
- 12小时制数字小时:({{ today | date:'hh' }})02
- 上午或下午的第几个小时:({{ today | date:'h' }})2
- 分钟格式化:
- 数字分钟数:({{ today | date:'mm' }})19
- 一个小时中的第几分钟:({{ today | date:'m' }})19
- 秒数格式化:
- 数字秒数:({{ today | date:'ss' }})24
- 一分钟中内的第几秒:({{ today | date:'s' }})24
- 毫秒数格式化:
- 毫秒数:({{ today | date:'sss' }})579
- 字符格式化:
- 上下午标识:({{ today | date:'a' }})PM
- 四位时区标识:({{ today | date:'Z' }})+0800
- 自定义日期格式化:
- 年月日:({{ today | date:'yyyy-MM-dd' }})2015-11-24
- 时分秒:({{ today | date:'HH:mm:ss.sss' }})14:19:24.579
本节课程源码
1
2
3
4
|
var myApp = angular.module( 'myApp' , []);
myApp.controller( 'MyController' ,[ '$scope' , '$parse' , function ($scope, $parse) {
$scope.today = new Date();
}]);
|