Function Updated 19 Oct 2026
new Date()()
Creates a date. Without arguments it returns the current date and time.
Differences from browser JavaScript:
new Date(year, month, day …)is created in UTC, not local time. The month is 0-based, as in JavaScript.- Values outside the valid range (month 13, day 31 in a 30-day month) throw an error instead of rolling over to the next month.
- A string that cannot be parsed throws an error instead of giving "Invalid Date". A date-only string ("2026-11-22") is read as local server time.
new Date(null)andnew Date(undefined)give the current time.- Docly extension:
new Date("15.11.2026", "dd.MM.yyyy")parses a string with an explicit format.
Parameters
This function takes no parameters.
Returns
A date object. Writing it directly gives the .NET format — use toISOString() or docly.format(date, "…") for output. Also available through the docly.getDate() function.
Example
Mixed HTML (or any text file) with inline JavaScript between hash signs.
<b>Raw Date:</b> #write(new Date())#<br>
<b>Formatted date:</b> #{
var d = new Date();
write(docly.format(d, "MMMM dd"));
}#The template above produces this output:
<b>Raw Date:</b> 11/01/2026 19:36:08 +01:00<br>
<b>Formatted date:</b>