Skip to content

Instantly share code, notes, and snippets.

@gdumitrescu
Created October 17, 2014 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdumitrescu/d4b2a47ca9d76b61cebd to your computer and use it in GitHub Desktop.
Save gdumitrescu/d4b2a47ca9d76b61cebd to your computer and use it in GitHub Desktop.
Format Date by language code // source http://jsbin.com/hezefewuwotu/5
<!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>
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