Getting the time
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!
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!
In JavaScript, when we talk about time, we’re concerned about 4 things:
The Date object has four methods that give you each of the 4 things:
getHours: Gets hours (0-23) according to local time.getMinutes: Gets minutes (0-59) according to local time.getSeconds: Gets seconds (0-59) according to local time.getMilliseconds: Gets milliseconds (0-999) according to local time.Loosely speaking, local time means the current time in your timezone. Your local time will be different from mine. We’ll talk about timezones in the next lesson.
Creating a custom time format is much easier than creating a custom date format. Create the following time formats:
08:34:23.456 (Hours:minutes:seconds.milliseconds)8:34am (or 8:34pm, depending on the time of the day)