TIME FILTER WITH AM/PM

2

(In order to Enlarge images Please Right Click and Open images in New Tab)

s1

s2

s3

 

Code Snippet=>

angular.module(“ToolsModule”).filter(‘timefilter’, function ($filter) {
return function (value) {
if (!value) { return ”; }

var hours = parseInt(value.substring(0, 2));
var minutes = parseInt(value.substring(3, 5));
var ampm = hours >= 12 ? ‘PM’ : ‘AM’;
hours = hours % 12;
hours = hours ? hours : 12;
minutes = minutes < 10 ? ‘0’ + minutes : minutes;
var strDateTime = hours + ‘:’ + minutes + ‘:’ + ‘ ‘ + ampm;
return strDateTime;
}
});

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s