Current Time Function Javascript

I want to write a function that will work in app lab that grabs or calculates the current time. The explanations I found online are a bit hard for me to wrap my head around for use in app lab. I would love some help/advice beyond Google it. Thanks!

var date = new Date();
var time = date.getHours() + ":" + date.getMinutes();
console.log(time);

image

Hi @jdonwells - you are always so helpful!

Just so I am understanding…

Date(), getHours(), and getMinutes() are all functions included in app lab (didn’t see it in documentation)?

It is in Javascript. App Lab has things from Javascript that are not explicitly mentioned.

We would say that Date() is a class and getHours(), getMinutes() are methods.

For when you have time…

When I print out date, I get “Object {}”, which is making me think of creating classes and objects in Java. What is Date() actually doing?

Just answered me :).

One more… Do you have a recommendation where I can learn more about javascript classes and methods that are widely used outside of app lab. A good manual or online tutorial environment?

I did find this helpful documentation on W3Schools (for anyone else who is interested) JavaScript Date Reference