Created
December 1, 2016 06:06
-
-
Save mehmetbebek/247e5d306acdba2551f49366fab8eb83 to your computer and use it in GitHub Desktop.
Moment.js Minutes to Hour(HH:mm) format
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
.filter('formatMinuteToHour', function () { | |
return function (mins) { | |
/* if (mins >= 24 * 60 || mins < 0) { | |
throw new RangeError("Valid input should be greater than or equal to 0 and less than 1440."); | |
} | |
*/ | |
var h = mins / 60 | 0, | |
m = mins % 60 | 0; | |
return moment().utc().hours(h).minutes(m).format("HH:mm"); | |
} | |
}) | |
$scope.formatMinuteToHour = function(mins){ | |
return $filter('formatMinuteToHour')(mins); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.filter('formatStringToDate', function () {
return function (date, oldDateFormat, newDateFormat) {
return moment(date, oldDateFormat).format(newDateFormat);
}
})
$scope.formatStringToDate = function (inputStr) {
return $filter('formatStringToDate')(inputStr, 'dd/MM/yyyy', 'D MMM YYYY');
};