robisim74/angular-l10n

How to display full name of the date?

ihor-zinchenko opened this issue · 6 comments

{{ TIMESTAMP | l10nDate:locale.language:{dateStyle: 'medium'} }}
I need to display in first case only day of the week, for example Mondey

What the correct way to do this?

@ihor-zinchenko as custom options, you can pass Intl.DateTimeFormatOptions (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat), like this:

<p>{{ today | l10nDate:locale.language:{ weekday: 'long' } }}</p>

@robisim74 hi! thanks) tell me please what the correct way to display numbers instead string

{{ today | l10nDate:locale.language:{ weekday: 'number' } }}

- for example 02 / 03 / 04

From the link above:

weekday
The representation of the weekday. Possible values are:
"long" (e.g., Thursday)
"short" (e.g., Thu)
"narrow" (e.g., T). Two weekdays may have the same narrow style for some locales (e.g. Tuesday's narrow style is also T).

If you need only the weekday number, you can just use JavaScript:

var day = new Date().getDay(); // Number from 0 to 6 (0=Sunday 1=Monday 2=Tuesday ...)

ok thanks!)

@robisim74 hi, could you please help me a bit? how i can display date like that: Mar 10, 2022 02:03
i tried:

{{ date | l10nDate:locale.language:{ month: 'short', day: '2-digit', year: 'numeric', hour: 'numeric', minute: 'numeric', hour12: false  } }}

but i've got Mar 10, 2022, 02:03 and i have no idea how to remove , symbol

I think the simplest method is the joining of the two parts:

{{ date | l10nDate:locale.language:{ month: 'short', day: '2-digit', year: 'numeric' } }}&nbsp;{{ date | l10nDate:locale.language:{ hour: 'numeric', minute: 'numeric', hour12: false } }}