-2

In my project, I have this in moment for time, this one,

  moment().format('LLL')    // June 9 2014 9:32 PM
  moment().format('D MMM YYYY[,] HH[:]mm z')

but if I use this in luxon how can i make this format in luxon, for example, given below,

   luxon.DateTime.utc().toFormat('')
   luxon.DateTime.now().toFormat('d MMM yyyy[,] HH[:]mm z')

Here if i use this, in luxon LLL it represents month as an abbreviated localized string and it might only show me the month only.

GCT
  • 43
  • 7
  • 1
    I would imagine that you should be able to take a look at the docs for moment and Luxon to figure this out! – phuzi Oct 31 '22 at 11:48

1 Answers1

1

From the docs.

moment.js

LLL = Month name, day of month, year, time

luxon.js

LLL = month as an abbreviated localized string

So looking a Luxon's docs, the closest is ff but the month is short. and fff but has the locale at the end.

If neither of those work for you, you could could maybe use.

LLLL d, yyyy t a

Keith
  • 22,005
  • 2
  • 27
  • 44
  • const format1 = 'fff'; const format3 = 'LLLL L, yyyy t'; console.log(`This fff into format Luxon -`, DateTime.local().toFormat(format1)); // This fff into format Luxon - 31 October 2022 at 12:00 WET console.log( `This LLL into format Luxon 3 -`, DateTime.local().toFormat(format3) ); // October 10, 2022 12:00 const format2 = 'LLL'; console.log(`This LLL format moment -`, moment().format(format2)); // This LLL format moment - October 31, 2022 12:01 PM – GCT Oct 31 '22 at 12:01
  • I think fff works well, but i am not finding AM. It is showing local WET. – GCT Oct 31 '22 at 12:02
  • 1
    @GCT Yeah, the docs show it with AM, but `LLLL L, yyyy t a'` seems to be the same as moments. eg. For me -> `toFormat('LLLL L, yyyy t a')` gives -> `October 10, 2022 12:05 PM` – Keith Oct 31 '22 at 12:08
  • Yes that also work for me when I add a that its showing the PM but the date in October 10 but not showing me local date October 31 – GCT Oct 31 '22 at 12:12
  • 1
    @GCT oops, yeah it should be -> `LLLL d, yyyy t a` – Keith Oct 31 '22 at 12:14