0

I have an angular template that displays the unix timestamp, which is a number type:

<span>{{timestamp}}</span>

That displays like:

<span>1391139098314</span>

Instead of the number though, I want a nice string to display:

<span>1/30/2014 7:32:37 PM</span>

I thought it would be as easy as changing the template to what you see below, but that doesn't work.

<span>{{ new Date(timestamp).toLocaleString() }}</span>

Can someone tell me what I need to do in my template instead of what is not working, shown directly above?

1
  • <span>{{ myFunctionOnTheScopeThatReturnsA(timestamp) }}</span> Commented Jan 31, 2014 at 3:36

1 Answer 1

2

Try date filter:

<span>{{timestamp | date:'M/dd/yyyy hh:mm:ss a'}}</span>

DEMO

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.