डाउनलोड पी.डी.एफ. ई-बुक्स
AJS - Filters date

date ये filter; number को date format में format किया जाता है |

Syntax for Date Filter in AngularJS

{{date_expression | date : format : timezone}}

Parameter for Date Filter in AngularJS

format : Optional. यहाँ पर date के लिए format दिया जाता है |

formatsDescriptionExample
aAM/PM according to timeAM
dday(1 to 31)5
ddday(01 to 31)05
EEEabbreviated weekday nameMon
EEEEfull weekday nameMonday
hhour(1 to 12)4
hhhour(01 to 12)04
HHour(0 to 23)4
HHHour(00 to 23)04
mminute(0 to 59)9
mmminute(00 to 59)09
Mmonth in number(1 to 12)2
MMmonth in number(01 to 12)02
MMMabbreviated month nameFeb
MMMMfull month nameFebruary
ssecond(0 to 59)8
sssecond(00 to 59)08
sssmillisecond(000 to 999)589
wweek(0 to 53)8
wwweek(00 to 53)08
yyear in 4 digits2017
yyyear in 2 digits17
yyyyyear in 4 digits2017
Ztimezome+530

 

In-Built format names का भी इस्तेमाल किया जाता है |

format nameformatExample
shortM/d/yy h:mm a2/4/2017 1:08 PM
shorDateM/d/yy2/4/17
shortTimeh:mm a1:08 PM
mediumMMM d, y h:mm:ss aFeb 4, 2017 1:08:05 PM
mediumDateMMM d, yFeb 4, 2017
mediumTimeh:mm:ss a1:08:05 PM
fullDateEEEE, MMMM d, ySaturday, February 4, 2017
longDateMMMM d, yFebruary 4, 2017

 

timezone : date formatting के लिए यहाँ पर timezone दिया जाता है |


Example for date Filter in AngularJS

Source Code :
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
<body>

<div ng-app="app" ng-controller="ctrl">
{{currtime | date}}<br />
{{currtime | date : 'd MMMM y'}}<br />
{{currtime | date : 'short'}}<br />
{{currtime | date : 'short' : 'GMT'}}<br />
</div>

<script>
var myapp = angular.module("app", []);
myapp.controller("ctrl", function($scope){
	$scope.currtime = new Date();
});
</script>


</body>
</html>
Output :
{{currtime | date}}
{{currtime | date : 'd MMMM y'}}
{{currtime | date : 'short'}}
{{currtime | date : 'short' : 'GMT'}}