0

I get time and format

{{transaction.submitTime | date:'yyyy-MM-dd HH:mm:ss Z'}}

It returns

2015-04-23 02:18:43 +0700

But I want to show without +0700, that hour will plus 7. How can I do that?

3
  • Could you explain what you mean in that last sentence? Commented Apr 23, 2015 at 4:50
  • So do you want it to display '2015-04-22 19:18.43' (i.e. UTC without the time zone) or '2015-04-23 02:18:43' (i.e. system time without the time zone)? Commented Apr 23, 2015 at 5:04
  • as your question. I want to get '2015-04-23 09:18:43' Commented Apr 23, 2015 at 7:20

3 Answers 3

3

Try this

d = new Date();
d.toLocaleString();       // -> "2/1/2013 7:37:08 AM"
d.toLocaleDateString();   // -> "2/1/2013"
d.toLocaleTimeString();  // -> "7:38:05 AM"
Sign up to request clarification or add additional context in comments.

1 Comment

The toLocale* methods are entirely implementation dependant, there is no guarantee of any of those formats appearing in a random browser.
0

Take a look at the format string you supplied in relation to the output you got:

yyyy-MM-dd HH:mm:ss Z
2015-04-23 02:18:43 +0700

Note how each element of the format string corresponds to an element of the output?

Z represents the time zone. To get rid of it, just change the format string:

yyyy-MM-dd HH:mm:ss

You'll then get a time string like this:

2015-04-22 09:48:36

1 Comment

Thanks. But Hour still not plus 7
0

You can use toLocaleString method.

var date = new Date()
alert(date.toLocaleString())

Comments

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.