Introduction
In this lab, we will learn how to convert a date into the extended ISO format (ISO 8601), including timezone offset. We will use the Date.prototype.getTimezoneOffset()
method to get the timezone offset and reverse it. Then, we will define a helper function to normalize any passed number to an integer and pad it to 2 digits using String.prototype.padStart()
. Finally, we will use the built-in methods in the Date
prototype to build the ISO 8601 string with timezone offset. By the end of this lab, you will have a better understanding of how to manipulate dates in JavaScript.