Created
October 17, 2014 05:36
-
-
Save gdumitrescu/d4b2a47ca9d76b61cebd to your computer and use it in GitHub Desktop.
Format Date by language code // source http://jsbin.com/hezefewuwotu/5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app="app"> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script> | |
<meta charset="utf-8"> | |
<title>Format Date by language code</title> | |
</head> | |
<body> | |
<div ng-controller="MainCtrl"> | |
<p>{{dates|formatDate:lng}}</p> | |
</div> | |
<script id="jsbin-javascript"> | |
angular | |
.module('app', []) | |
.controller('MainCtrl', function($scope) { | |
$scope.dates = new Date(); | |
$scope.lng = 'fr'; | |
}) | |
.filter('formatDate', function($filter) { | |
return function(dt, lng) { | |
if (lng === 'en') { | |
return $filter('date')(dt, 'MMM dd, yyyy'); | |
} else if (lng === 'fr'){ | |
return $filter('date')(dt, 'dd MMM yyyy'); | |
} | |
}; | |
}); | |
</script> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html ng-app="app"> | |
<head> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"><\/script> | |
<meta charset="utf-8"> | |
<title>Format Date by language code</title> | |
</head> | |
<body> | |
<div ng-controller="MainCtrl"> | |
<p>{{dates|formatDate:lng}}</p> | |
</div> | |
</body> | |
</html></script> | |
<script id="jsbin-source-javascript" type="text/javascript">angular | |
.module('app', []) | |
.controller('MainCtrl', function($scope) { | |
$scope.dates = new Date(); | |
$scope.lng = 'fr'; | |
}) | |
.filter('formatDate', function($filter) { | |
return function(dt, lng) { | |
if (lng === 'en') { | |
return $filter('date')(dt, 'MMM dd, yyyy'); | |
} else if (lng === 'fr'){ | |
return $filter('date')(dt, 'dd MMM yyyy'); | |
} | |
}; | |
});</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular | |
.module('app', []) | |
.controller('MainCtrl', function($scope) { | |
$scope.dates = new Date(); | |
$scope.lng = 'fr'; | |
}) | |
.filter('formatDate', function($filter) { | |
return function(dt, lng) { | |
if (lng === 'en') { | |
return $filter('date')(dt, 'MMM dd, yyyy'); | |
} else if (lng === 'fr'){ | |
return $filter('date')(dt, 'dd MMM yyyy'); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment