Adding JavaScript code into angular template expression

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?

Answers


Try date filter:

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

DEMO


Need Your Help

QT in Visual Studios 2008/2010

visual-studio visual-studio-2008 visual-studio-2010 qt

I installed the SDK for QT for Visual studios. I installed the plugin. I created a simple project in QT Creator with just a dialog.

TypeError: 'long' object is not callable

python

I have steam coming out of my head now but I can't figure out what is wrong with my code.