Formatting dates Last updated: 09. Sep 2024
Information about formatting dates and time (datetime) with the Docly format function.
Docly extends JS to handle dates the same way .NET does (through its docly... functions), as Javascript has a very poor handling of dates.
Important! To set correct language first use the docly.SetCulture function:
https://developers.docly.net/JavaScript/Output-functions/SetCulture
To format a date use the docly.format function:
https://developers.docly.net/JavaScript/Output-functions/Format
Example:
/* Uses "new Date" which gives "Now" value */
#docly.format(new Date(), "dd. MMM yyyy")#
/* Got a string in a date? */
#docly.format(new Date(mystring), "dd. MM yy")#
Format specifier | Description | Examples |
---|---|---|
"d" | The day of the month, from 1 through 31. | 2009-06-01T13:45:30 -> 1 2009-06-15T13:45:30 -> 15 |
"dd" | The day of the month, from 01 through 31. | 2009-06-01T13:45:30 -> 01 2009-06-15T13:45:30 -> 15 |
"ddd" | The abbreviated name of the day of the week. | 2009-06-15T13:45:30 -> Mon (en-US) |
"dddd" | The full name of the day of the week. | |
"h" | The hour, using a 12-hour clock from 1 to 12. | |
"hh" | The hour, using a 12-hour clock from 01 to 12. | |
"H" | The hour, using a 24-hour clock from 0 to 23. | |
"HH" | The hour, using a 24-hour clock from 00 to 23. | |
"m" | The minute, from 0 through 59. | |
"mm" | The minute, from 00 through 59. | |
"M" | The month, from 1 through 12. | |
"MM" | The month, from 01 through 12. | |
"MMM" | The abbreviated name of the month. | |
"MMMM" | The full name of the month. | |
"s" | The second, from 0 through 59. | |
"ss" | The second, from 00 through 59. | |
"y" | The year, from 0 to 99. | |
"yy" | The year, from 00 to 99. | |
"yyy" | The year, with a minimum of three digits. | |
"yyyy" | The year as a four-digit number. | |
"yyyyy" | The year as a five-digit number. | |
"tt" | The AM/PM designator. | 2009-06-15T13:45:30 -> PM (en-US) |
\ | The escape character. | |
Any other character | The character is copied to the result string unchanged | 2009-06-15T01:45:30 (arr hh:mm t) -> arr 01:45 A |