The formatString method has been added to the Date object. You can use it to format a date however you please. It takes one parameter that is a template for how you want the date to be formatted.
Below is a table of all the components you can use in your template to get the desired date format.
These can be combined to create your own date templates to use in your tiddlywiki. For example to display a date like, 27th January 2011 you'd need a template like:
Below is a table of all the components you can use in your template to get the desired date format.
| Template Part | Result Type |
| hh12 | Current hour using 12 hour clock |
| 0hh | Current hour using 24 hour clock |
| hh | Current hour |
| mmm | Three character month representation |
| 0mm | Current minute |
| mm | Current minute |
| 0ss | Current second |
| ss | Current second |
| AM or PM | Returns whether it is am or pm (uppercase) |
| am or pm | Returns whether it is am or pm (lowercase) |
| wYYYY | 4 digit year |
| wYY | 2 digit year |
| YYYY | 4 digit year |
| YY | 2 digit year |
| MMM | Full month title |
| 0MM | Month number prefixed with 0 (if req) |
| MM | Month number |
| 0WW | Week number prefixed with 0 (if req) |
| WW | Week number |
| DDD | Full day name |
| ddd | 3 char day name |
| ~0DD | Day number prefixed with 0 (if req) |
| DDth | Day number with correct suffix (th, rd, st) |
| DD | Day number |
These can be combined to create your own date templates to use in your tiddlywiki. For example to display a date like, 27th January 2011 you'd need a template like:
var template = "DDth MMM YYYY"; date.formatString(template);Or to display a date and time like, 27th Jan 18:54:23
var template = "DDth mmm hh:mm:ss"; date.formatString(template);