{hero}

val()

Since: DateTime 1.0.0

Get / set the value of the DateTime instance.
Please note - this property requires the DateTime extension for DataTables.

Description

Get or set the value for the DateTime instance. If the set parameter is provided then a DateTime instance is provided for chaining. If not then the value stored within DateTime is returned as a Date.

Types

function val()

Description:

Get the value of the DateTime instance.

Returns:

Date instance representing the current date selected within the DateTime instance.

function val(set)

Description:

Set the value of the DateTime instance.

Parameters:
Returns:

Self for chaining.

Examples

Get a value from the input:

let el = document.getElementById('example');
let dt = new DateTime(el);

el.addEventListener('change', function () {
	console.log('Selected value is: ', dt.val());
});

Set a value into the input:

let dt = new DateTime(document.getElementById('example'));

dt.val('2021-12-31');