0

I am using datetimepicker.js.

I have the following code:

Partial HTML:

<div ng-hide="editingData[x.date]">{{x.date|date}} </div>

So my date is coming as:

May 21, 2015 2:52:29 PM

Expected:

May 21, 2015 2:52:29 PM IST

So Is there any easy way to add timezone in angularjs ?

I am having moment.js included as well and found that it can manipulate dates well. Can it be helpful ?

1
  • Try date:'dd-M-yyyy H:mm Z' Commented May 21, 2015 at 11:01

1 Answer 1

3

Displaying local time zone

may be this will help you :)

<div ng-app ng-controller="MyCtrl">
    {{date | date:'MMM dd yyyy - h:mm:ss a '}} {{z}}

</div>

function MyCtrl($scope) {
    $scope.date = new Date();

    var now = new Date().toString();
    $scope.z = now.indexOf('(') > -1 ?
    now.match(/\([^\)]+\)/)[0].match(/[A-Z]/g).join('') :
    now.match(/[A-Z]{3,4}/)[0];
    if ($scope.z == "GMT" && /(GMT\W*\d{4})/.test(now)) {
       $scope.z = RegExp.$1;}
}

Working js fiddle

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.