# How to get the current day, month, and year in JavaScript

By Atta Ur Rehman Shah (https://attacomsian.com/about). Published Sep 18, 2021. Topics: JavaScript.
Canonical URL: https://attacomsian.com/blog/javascript-date-get-day-month-year

> A quick guide to learn how to get the current day, month, and year from a date object in JavaScript. 

The `Date` object methods `getDate()`, `getMonth()`, and `getFullYear()` can be used to retrieve day, month, and full year from a date object in JavaScript.

Here is an example:

```javascript
const date = new Date(2021, 8, 18);

const day = date.getDate();
const month = date.getMonth() + 1; // getMonth() returns month from 0 to 11
const year = date.getFullYear();

const str = `${day}/${month}/${year}`;

console.log(str);
// 18/9/2021
```

Note that the `getDate()`, `getMonth()`, and `getFullYear()` methods return the date and time in the local time zone of the computer where the code is running.

To get the date and time in the universal timezone (UTC), just replace the above methods with the `getUTCDate()`, `getUTCMonth()`, and `getUTCFullYear()` respectively:

```javascript
const date = new Date(2021, 8, 18);

const day = date.getUTCDate();
const month = date.getUTCMonth() + 1; // getUTCMonth() returns month from 0 to 11
const year = date.getUTCFullYear();

const str = `${day}/${month}/${year}`;

console.log(str);
// 18/9/2021
```
