DEV Community

loading...

Getting MonthName from new Date()

Sekti
Keep moving forward. Learn well not learn fast.
・1 min read
const today = new Date()

// Default
today.toLocaleString('default', { month: 'long' }) // February
today.toLocaleString('default', { month: 'short' }) // Feb

// Indonesia
today.toLocaleString('id-ID', { month: 'long' }) // Februari
today.toLocaleString('id-ID', { month: 'short' }) // Feb

// English - GB
today.toLocaleString('en-GB', { month: 'long' }) // February
today.toLocaleString('en-GB', { month: 'short' }) // Feb

// English - US
today.toLocaleString('en-US', { month: 'long' }) // February
today.toLocaleString('en-US', { month: 'short' }) // Feb
Enter fullscreen mode Exit fullscreen mode

Discussion (0)