How to display localtime in JQuery and AngularJS

How to display the localtime in JQuery and AngularJS?

I have tried the jquery.localtime-0.5.js but it does not work at all.

Error 1: Cannot read property 'setFormat' of undefined
Error 2: Cannot read property 'getFormat' of undefined
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chuang4630Author Commented:
I have followed the example:

<script type="text/javascript" src=""></script>
<script type="text/javascript" src="jquery.localtime-0.5.js"></script>
<script type="text/javascript">$.localtime.setFormat("yyyy-MM-dd HH:mm");</script>

<span class="localtime">2010-12-12 19:27:00Z</span>

But it does not work
Rainer JeschorCommented:
not sure but at least you are using very old versions both of jQuery and jQuery.localtime.

It works both locally and on jsFiddle using the latest jQuery 1.11 and the latest jquery.localtime:

But it is very picky on where you add the script src (head / body).

And second: is your site using HTTPS ? Because you load jquery from Google site using HTTP - this might be also an issue.

You use a Javascript Date object and format it with a filter.

and if you don't specify a time zone the zone of the browser will be used (which corresponds to local time)

You usually have to set this up in the controller :-

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.