HTML | DOM del dateTime Property

The DOM del dateTime Property is used to set or return the value of the DateTime attribute of the <del> Element. This attribute is used to specify the date and time of the deleted text. The date-time is inserted in the format YYYY-MM-DDThh:mm:ssTZD.

Syntax:

  • It is used to return the DateTime property.
    delObject.dateTime
  • It is used to set the dateTime property.
    delObject.dateTime = YYYY -MM-DDThh:mm:ssTZD
  • Property Values:



    • YYYY-MM-DDThh:mm:ssTZD YYYY-MM-DDThh:mm:ssTZD It specifies the date and time when the text was deleted

    Explanation:

    • YYYY – year (e.g. 2009)
    • MM – month (e.g. 01 for January)
    • DD – day of the month (e.g. 08)
    • T – a required separator
    • hh – hour (e.g. 22 for 10.00pm)
    • mm – minutes (e.g. 55)
    • ss – seconds (e.g. 03)
    • TZD – Time Zone Designator (Z denotes Zulu, also known as Greenwich Mean Time)

    Return value: It returns a string value which represent the date and time when the text was deleted.

    Example-1: This Example returns the dateTime Property.

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html>
      
    <head>
        <title>
          HTML DOM Del dateTime
      </title>
        <style>
            del {
                color: red;
            }
              
            ins {
                color: green;
            }
        </style>
    </head>
      
    <body style="text-align:center;">
        <h1>
          GeeksforGeeks
      </h1>
      
        <h2>
          DOM Del dateTime Property
      </h2>
      
        <p>
            GeeksforGeeks is a 
          <del id="GFG" 
               datetime="2018-11-21T15:55:03Z"
                mathematical</del
          <ins>computer</ins> science portal
        </p>
      
        <button onclick="myGeeks()">
            Submit
        </button>
      
        <p id="sudo"></p>
      
        <script>
            function myGeeks() {
                var g = 
                    document.getElementById(
                      "GFG").dateTime;
                
                document.getElementById(
                  "sudo").innerHTML = g;
            }
        </script>
      
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before Clicking On Button: :

    After Clicking On Button: :

    Example-2 :This Example sets the dateTime Property.

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html>
      
    <head>
        <title>
          HTML DOM Del dateTime
      </title>
        <style>
            del {
                color: red;
            }
              
            ins {
                color: green;
            }
        </style>
    </head>
      
    <body style="text-align:center;">
        <h1>GeeksforGeeks</h1>
      
        <h2>
          DOM Del dateTime Property
      </h2>
      
        <p>
            GeeksforGeeks is a 
          <del id="GFG" 
               datetime="2018-11-21T15:55:03Z"
                mathematical</del
          <ins>computer</ins> science portal
        </p>
      
        <button onclick="myGeeks()">
            Submit
        </button>
      
        <p id="sudo"></p>
      
        <script>
            function myGeeks() {
                var g = 
                    document.getElementById(
                      "GFG").dateTime = "2013-11-15T21:40:07Z";
                
                document.getElementById(
                  "sudo").innerHTML = 
                  "The value of the dateTime attribute was changed to "
                + g;
            }
        </script>
      
    </body>
      
    </html>

    chevron_right

    
    

    Output :
    Before Clicking On Button:

    After Clicking On Button:

    Supported Browsers: The browser supported by DOM Del dateTime property are listed below:

    • Google Chrome
    • Internet Explorer 10.0 +
    • Firefox
    • Opera
    • Safari


    My Personal Notes arrow_drop_up

    Check out this Author's contributed articles.

    If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

    Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



    Improved By : shubham_singh



    Article Tags :
    Practice Tags :


    Be the First to upvote.


    Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.