Filter for change Date Time format (MM-dd-yyyy HH:mm) in Angular Js

mm-dd-yyyy HH:MM
date formats
angular js

Angular.js has a built-in date filter. But as per our requirements we can use filers to change date formats 

angular.module('surgi').
filter('ChangeTimeFormat', function($filter)
{
	return function(input)
	{
		if(input == null){ return ""; }
		var _date = $filter('date')(new Date(input), 'HH:mm');
		return _date;
	};
});

This filter load in your js file. This filter calls from html. Here is the sample code to call the filter

<p>{{dt | ChangeTimeFormat}}<p>

 

 

 

 

You might also like:

Functions in javascript

25-05-2018 functions javascript es5 es6 arrow functions named functions Closures Nested Functions Callbacks Arrow functions.

Use java script file client side and server side at a time in node js

30-07-2017 node js include call javascript

Detect AdBlock with JavaScript in my browser

30-07-2017 AdBlock javascript detect

How to get id by using name attribute in javascript

20-03-2017 html id name javascript

Convert Time 24 hrs to 12 hrs format In javascript

12-03-2017 date javascript 12hrs convert