0

My filter:

.filter('emedicineDateTimeFormat', function ($filter) {
    return function (input) {
        if (input == null) { return ""; }

        var date = $filter('date')(new Date(input), 'dd.MM.yyyy hh:mm:ss');
        return date.toUpperCase();

    };
});

if Input is: 2017-01-04T14:30:00

then output is 04.01.2017 03:15:00

and not 04.01.2017 14:15:00

Why?

1 Answer 1

2

If you want get 24-hours time use upper-cased H. An example is here.

'dd.MM.yyyy HH:mm:ss'

Are you sure that you didn't misspell in output and expected result? Do you live in UTC+01:00 timezone?

By default AngularJS uses browser timezone. If you want use UTC you should pass the 3rd argument to date filter 'UTC'. Look here.

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

8 Comments

Yes I am living in UTC+1 timezone. But it is funny why automatically changed?
and jsfiddle returns also 04.01.2017 15:30:00 and not 04.01.2017 14:30:00
My JSFiddle returns 04.01.2017 17:30:00 ;-) because I live in UTC+03:00.
i want it in local
From AngularJS date filter manual: If not specified, the timezone of the browser will be used.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.