Open In App

HTML DOM del dateTime Property

The 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:



Property Values: It specifies the date and time when the text was deleted.

Explanation:



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.




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM Del dateTime Property
    </title>
 
    <style>
        body {
            text-align: center;
        }
 
        del {
            color: red;
        }
 
        ins {
            color: green;
        }
    </style>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
 
    <h2>HTML 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()">
        Click Here!
    </button>
 
    <p id="result"></p>
 
    <script>
        function myGeeks() {
            let dateTimeVal = document
                .getElementById("GFG").dateTime;
 
            document.getElementById("result")
                .innerHTML = dateTimeVal;
        }
    </script>
</body>
 
</html>

Output:

Example 2: This example sets the dateTime property.




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM Del dateTime Property
    </title>
 
    <style>
        body {
            text-align: center;
        }
 
        del {
            color: red;
        }
 
        ins {
            color: green;
        }
    </style>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
 
    <h2>HTML 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()">
        Click Here!
    </button>
 
    <p id="result"></p>
 
    <script>
        function myGeeks() {
            let dateTimeVal = document.getElementById("GFG")
                .dateTime = "2013-11-15T21:40:07Z";
 
            document.getElementById("result").innerHTML =
                "Value of dateTime Attribute Changed to "
                + dateTimeVal;
        }
    </script>
</body>
 
</html>

Output:

Supported Browsers:


Article Tags :