Tuesday 1 February 2022

Create a written date in Javascript 'moment' library.

The dates I'm outputting at the moment look like this. 



Which looks like this with 'moment' 

const written_date = moment(my_date).format('MMM d YYYY');


However, what I want is more of a fullText response. 

Moment has these name types. 

type RelativeTimeKey = 's' | 'ss' | 'm' | 'mm' | 'h' | 'hh' | 'd' | 'dd' | 'w' | 'ww' | 'M' | 'MM' | 'y' | 'yy';
type CalendarKey = 'sameDay' | 'nextDay' | 'lastDay' | 'nextWeek' | 'lastWeek' | 'sameElse' | string;
type LongDateFormatKey = 'LTS' | 'LT' | 'L' | 'LL' | 'LLL' | 'LLLL' | 'lts' | 'lt' | 'l' | 'll' | 'lll' | 'llll';


For what I wanted to achieve this works for me. 

const written_date = moment(my_date).format('ddd LL');






No comments: