Difference between datetime and datetime-local in HTML5

The datetime-local input is different from the other one in that it excludes the time zone. Use datetime-local if your application doesn't care about the time zone. The datetime input type is still catching up with some browsers.

Let?s look into further for getting better understanding between datetime and datetime-local in HTML5

HTML5 datetime

The machine-readable date and time of the

Syntax

Following is the syntax for HTML datetime

Let?s look into the following example

Example

In the following example we are using the HTML



    
        

HTML dateTime Attribute

Gandhi Jayathi

Output

When the script gets executed, it will generate an output consisting of the text mentioned with the HTML datetime attribute and display it on the webpage.

Example

Considering the another example for datetime attribute.



   
      
Date and Time :

Output

On running the above script, the output window will pop up and display the input field for the user to enter the date and time mentioned with the datetime attribute on the webpage.

HTML5 datetime-local

Elements of type With the help of datetime-local, users can quickly enter a date and time, as well as the year, month, and day, as well as the time in hours and minutes.

Syntax

Following is the syntax for datetime-local.


Let?s look into the following examples.

Example

In the following we are using the datetime-local for input type.



    
        

Output

When the script gets executed, it will generate an output consisting of an input field allowing the user to enter the date of birth mentioned with datetime-local on the webpage.

Example

Let?s look into the another example of usage of datetime-local.



   
      
Local Date and Time :

Output

On running the above script, it will generate an output making the user enter the input by providing the input field mentioned with datetime-local on the webpage.

Updated on: 2023-10-11T15:43:21+05:30

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements