Date & Time with Timezone display using Angularjs Date & Time with Timezone display using Angularjs angularjs angularjs

Date & Time with Timezone display using Angularjs


But in versions 1.3.x only supported timezone is UTC,You can use external js if working with 1.3.x like Moment js

{{ user Defined date| date: 'MMM d, y H:mm:ss' : 'UTC' }}

Since version 1.4.0-rc.0 AngularJS supports other timezones too.

In HTML Template Binding

{{ date_expression | date : format : timezone}}

In JavaScript

$filter('date')(date, format, timezone)

More...


use the following code:

<html><head><title>Localization App</title></head><body><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script><script type="text/javascript">    var app=angular.module('myApp',[]);    app.controller('myCtrl',function($scope)    {        $scope.CurrentDate = new Date();        });</script><div ng-app="myApp" ng-controller="myCtrl">     Date : {{CurrentDate | date:'dd/MM/yyyy'}}  </br>     Date_1 : {{CurrentDate | date:'dd, MMMM yyyy'}}  </br>     Time : {{CurrentDate | date: 'hh:mm:ss a'}} </br>      Time_1 : {{CurrentDate | date: 'HH:mm:ss Z'}} </br> </div></body></html>

Output:

Date : 13/12/2017
Date_1 : 13, December 2017
Time : 10:33:42 AM
Time_1 : 10:33:42 +0530