In JavaScript, when we talk about time, we’re concerned about 4 things:
Hours
Minutes
Seconds
Milliseconds
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.
Exercise
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)