Date Format
Basic
Date module allow you to format a date according to a pattern.
open Fable.PowerPack
Date.Format.localFormat Date.Local.englishUK "yyyy-MM-dd hh:mm:ss" testDate
// Result: "2017-08-22 01:00:33"
Date.Format.localFormat Date.Local.englishUK "dddd, MMMM dd, yyyy" testDate
// Result: "Tuesday, August 22, 2017"
Localization
open Fable.PowerPack
Date.Format.localFormat Date.Local.french "dddd, dd MMMM yyyy" testDate
// Result: "Mardi, 22 août 2017"
// Use default date format:
Date.Format.localFormat Date.Local.french Date.Local.french.Date.DefaultFormat testDate
// Result: "22/3/2017"
Date.Format.localFormat Date.Local.englishUS Date.Local.englishUS.Date.DefaultFormat testDate
// Result: "3/22/2017"
Supported formats
Here is all the pattern supported and their description. This patterns are from .Net so you can find more information here.
| Pattern | Description |
|---|---|
| d | The day of the month, from 1 through 31 |
| dd | The day of the month, from 01 through 31 |
| ddd | The abbreviated name of the day of the week |
| 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 00 through 59 |
| ss | The second, from 00 through 59 |
| t | The first character of the AM/PM designator |
| tt | The AM/PM designator |
| 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 |
| \ | Escape the next character |