How to get a Date

Published on: June 18, 2017

Welcome to the 52nd Easy JavaScript tutorial, part of Let's work with the Date object in JavaScript. Like the number, string, and array objects, the Date object has many useful methods that you can use. This is just a list of a few of them. Find more at W3Schools

Method Description
getDate()/getUTCDate() Returns the day of the month (from 1-31)
getDay()/getUTCDay() Returns the day of the week (from 0-6)
getMonth()/getUTCMonth() Returns the month (from 0-11)
getFullYear()/getUTCFullYear() Returns the year
getHours()/getUTCHours() Returns the hour (from 0-23)
getMinutes()/getUTCMinutes() Returns the minutes (from 0-59)
getSeconds()/getUTCSeconds() extract part of a string, first parameter is the start position, and second is the length

In this tutorial we're going to learn how to get a date and do a bit of formatting. 

To fork the fiddle and follow along:

Remember to checkout the Resources section below for associated downloadable content, JSFiddle links, and other resources. Watch the video and follow along!