Function Updated 17 Oct 2026
isDateTime(value)
Checks if the value is a date/time, or text that can be read as one. Text is first parsed with .NET's general date parser (invariant culture), so this accepts more formats than isDate — including plain dates such as 2023-01-01 and US-style dates such as 01/31/2023.
Parameters
valueobjectrequiredValue to try to check if is a datetime that can be converted
Returns
True if the value is or can be converted to a datetime.
Example
Normal JavaScript, running in the browser or on the Docly™ server.
let text = "2023-01-01T13:45"; // a datetime
let text2 = "20230101"; // not a datetime
if (docly.isDateTime(text)) {
console.log("Text is a datetime!");
}
if (!docly.isDateTime(text2)) {
console.log("Text2 is not a datetime!");
}
/*
Formats supported:
"yyyy-MM-ddTHH:mm:ss.FFFFFFFZ", // Full ISO with timezone
"yyyy-MM-ddTHH:mm:ssZ", // ISO with seconds
"yyyy-MM-ddTHH:mmZ", // ISO without seconds
"yyyy-MM-ddTHH:mm:ss.FFFFFFF", // Full ISO without timezone
"yyyy-MM-ddTHH:mm:ss", // Basic datetime
"yyyy-MM-dd HH:mm:ss", // Space separated
"yyyy-MM-dd HH:mm" // Basic datetime without seconds
*/