# Current Time Function Javascript

**URL:** <https://forum.code.org/t/current-time-function-javascript/36027>\
**Category:** Coding and Debugging Help\
**Created:** [March 16, 2022, 2:18pm UTC](https://forum.code.org/t/current-time-function-javascript/36027 "2022-03-16T14:18:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbrunner](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mbrunner/32/5271_2.png) [@mbrunner](https://forum.code.org/u/mbrunner)\
**Post date:** [March 16, 2022, 2:18pm UTC](https://forum.code.org/t/current-time-function-javascript/36027/1 "2022-03-16T14:18:16Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jdonwells](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/jdonwells/32/7900_2.png) [@jdonwells](https://forum.code.org/u/jdonwells)\
**Post date:** [March 16, 2022, 3:52pm UTC](https://forum.code.org/t/current-time-function-javascript/36027/2 "2022-03-16T15:52:47Z")

</div>

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

```

![image](https://us1.discourse-cdn.com/flex016/uploads/codeorgforum/original/2X/6/6b23f5a94e19c11ec9fded2adf2e21edc73c11a0.png)

---

<div class="post-metadata">

**Author:** ![mbrunner](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mbrunner/32/5271_2.png) [@mbrunner](https://forum.code.org/u/mbrunner)\
**Post date:** [March 16, 2022, 4:17pm UTC](https://forum.code.org/t/current-time-function-javascript/36027/3 "2022-03-16T16:17:03Z")

</div>

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)?

---

<div class="post-metadata">

**Author:** ![jdonwells](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/jdonwells/32/7900_2.png) [@jdonwells](https://forum.code.org/u/jdonwells)\
**Post date:** [March 16, 2022, 4:19pm UTC](https://forum.code.org/t/current-time-function-javascript/36027/4 "2022-03-16T16:19:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mbrunner](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mbrunner/32/5271_2.png) [@mbrunner](https://forum.code.org/u/mbrunner)\
**Post date:** [March 16, 2022, 4:22pm UTC](https://forum.code.org/t/current-time-function-javascript/36027/5 "2022-03-16T16:22:13Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mbrunner](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mbrunner/32/5271_2.png) [@mbrunner](https://forum.code.org/u/mbrunner)\
**Post date:** [March 16, 2022, 4:22pm UTC](https://forum.code.org/t/current-time-function-javascript/36027/6 "2022-03-16T16:22:42Z")

</div>

Just answered me :).

---

<div class="post-metadata">

**Author:** ![mbrunner](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mbrunner/32/5271_2.png) [@mbrunner](https://forum.code.org/u/mbrunner)\
**Post date:** [March 16, 2022, 4:57pm UTC](https://forum.code.org/t/current-time-function-javascript/36027/7 "2022-03-16T16:57:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mbrunner](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mbrunner/32/5271_2.png) [@mbrunner](https://forum.code.org/u/mbrunner)\
**Post date:** [March 16, 2022, 5:23pm UTC](https://forum.code.org/t/current-time-function-javascript/36027/8 "2022-03-16T17:23:41Z")

</div>

I did find this helpful documentation on W3Schools (for anyone else who is interested) [JavaScript Date Reference](https://www.w3schools.com/jsref/jsref_obj_date.asp)
