The Date object

Hey ,

I'm thrilled to help you learn JavaScript. Unfortunately, you've landed on a page where you cannot access with your current purchase.

Please upgrade (use this link) access this content.

I'm super eager to help you learn more!

The Date object

What’s the date today?

You can tell the date physically if you have a calendar around you. You can also tell the time if you have a clock. In JavaScript, we can tell the date and time with the Date object.

Here’s what it looks like:

const date = new Date()

If you console.log date, you’ll get a log that tells you four things:

  1. The day of the week (like Wednesday)
  2. The date today (like Jan 23 2019)
  3. The time now (like 17:21:13)
  4. The timezone offset (like GMT+8000 Singapore Standard Time)
Wed Jan 23 2019 17:21:13 GMT+0800 (Singapore Standard Time)

There’s more things you can do with the Date object. Let’s go through them all in the next few lessons.