How can I get the name of the month in nominative format?
import { format } from 'date-fns';
import { ru } from 'date-fns/locale';
format(new Date(), 'MMMM', { locale: ru }); // июня
How can I get the name like юинь
instead of июня
?
How can I get the name of the month in nominative format?
import { format } from 'date-fns';
import { ru } from 'date-fns/locale';
format(new Date(), 'MMMM', { locale: ru }); // июня
How can I get the name like юинь
instead of июня
?
I was able to find a solution. To get the stand-alone name of the month the LLLL
format should be used.
The working code should look like this:
import { format } from 'date-fns';
import { ru } from 'date-fns/locale';
format(new Date(), 'LLLL', { locale: ru }); // июнь
See documentation -> Month (stand-alone): https://date-fns.org/v2.14.0/docs/format
There are a few patterns you can use.
Use the LLLL format to get full month names. I have tried and it worked! example:
import {format} from 'date-fns';
const formattedDate = format(new Date(), 'LLLL');
© 2022 - 2025 — McMap. All rights reserved.