format(value, format) Last updated: 30. May 2026

Formats a number or date into a string by given format.

Parameters

Name Type Description
value object

Value to format into a string.

format string

Format string to format the value to:

For date fields:
/JavaScript/Date and time functions/Formatting dates

For number objects:
/JavaScript/Output functions/Formatting numbers

Returns

Value in specified format as string.

Example

Code example (#JS)

#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.
#{
    var dt = new Date();
    write(docly.format(dt, "dd. MMM yyyy"));
}#

Output

The #JS code above produces the output shown below:
05. Jun 2026