From the course: HTML Essential Training

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Date and time

Date and time

- Date and time-based content is something that is commonly used on the web. For example, news sites include publish dates on their articles, and social media platforms display timestamps for user posts. This can help us understand how old or recent the content is. It can also be used to add functionality, such as calendar reminders, or to search for results based on a date range. In HTML, the time element is used to define a specific period in time. The content you want to display in the browser is added between the tags. This can be whatever format you prefer. Use the datetime attribute to format the date into machine-readable format. The values can be represented as time on a 24-hour clock, a calendar date, or a duration. To define the time, the values must follow these formats, hours and minutes, hours, minutes, and seconds, or hours, minutes, seconds, and milliseconds. To define the dates, the value can include the year and month, the year, month and day, or just the month and…

Contents