{{new Date() | date:'yyyy-MM-dd HH:mm:ss Z'}} errors

1,338 views
Skip to first unread message

Marc B

unread,
Feb 25, 2014, 2:36:43 PM2/25/14
to ang...@googlegroups.com
Hello,

I want to display the current time. So I use the date filter on a Date instance:

{{new Date() | date:'yyyy-MM-dd HH:mm:ss Z'}}

But this gives me as output {{new Date() | date:'yyyy-MM-dd HH:mm:ss Z'}}    

FireBug console shows:

Error: [$parse:syntax] Syntax Error: Token 'Date' is an unexpected token at column 5 of the expression [new Date() | date:'yyyy-MM-dd HH:mm:ss Z'] starting at [Date() | date:'yyyy-MM-dd HH:mm:ss Z'].

Can't I use a Date object as input for the Date filter????

Lars Christian Jensen

unread,
Feb 25, 2014, 4:36:44 PM2/25/14
to ang...@googlegroups.com


On Tuesday, February 25, 2014 8:36:43 PM UTC+1, Marc B wrote:
Hello,

I want to display the current time. So I use the date filter on a Date instance:

{{new Date() | date:'yyyy-MM-dd HH:mm:ss Z'}}
 
Hi,

'new Date()' is not a valid Angular expression. Angular expressions may look JavaScript, but it's not. See http://docs.angularjs.org/guide/expression 

-- 
thanks, Lars

Marc B

unread,
Feb 25, 2014, 4:43:36 PM2/25/14
to ang...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages