Defining and Formatting Dates
Welcome to the "Defining and Formatting Dates" Practice Lab. In this module, you will be provided with the instructions and devices needed to develop your hands-on skills.
Already have an account? Sign In »

Introduction
Welcome to the Defining and Formatting Dates Practice Lab. In this module, you will be provided with the instructions and devices needed to develop your hands-on skills.
Exam Objectives
The following exam objective is covered in this lab:
- 2.3 Complete and debug code that uses objects
Lab Duration
It will take approximately 20 minutes to complete this lab.
Exercise 1 - Defining and Formatting Dates
Date and time are important entities on dynamic web pages. As a developer, you may prefer to perform various tasks related to date and time such as retrieving and formatting the day, month, weekday, hours, minutes, seconds, etc. In JavaScript, you need not create different user-defined functions to handle date and time on web pages. There is a built-in Date object that helps you to work with date and time. The Date object has a list of built-in methods, which you can use to retrieve and format the date and time. You cannot use the Date object directly in your program. You need first to create an instance of the Date object using the new keyword. You need to access the Date object methods using the instance.
In this exercise, you will learn to define and format dates in JavaScript. The first task in this exercise will be to create a new folder named DigitalClock on PLABWIN10 Desktop, add the folder to a Visual Studio Code workspace, and save the workspace with the name DigitalClock. You will create a new HTML page named DigitalClock.html in the DigitalClock workspace.
In the second task, you will write JavaScript code to use the built-in Date object in DigitalClock.html. You will embed the code in the HTML page and run the page in Google Chrome web browser.
Learning Outcomes
After completing this exercise, you will be able to:
- Create a Date object
- Format dates
See the full benefits of our immersive learning experience with interactive courses and guided career paths.