Rick Goodrow
07/11/2024, 4:44 PMDate()
object because instead of returning month name, it's just returning a YYYY-MM-DD
output.
for (let i = 1; i <= 12; i++) {
monthField.addSelectOption({
value: i,
text: new Date(`${i}/1`).toLocaleDateString('en-US', {month: 'long'}),
isSelected: i === currentMonth,
});
}
in debugger console
new Date('1/1')
Date 2001-01-01T08:00:00.000Z
new Date('1/1').toLocaleDateString('en-US', { month: 'long' })
"2001-01-01"
battk
07/11/2024, 5:06 PMbattk
07/11/2024, 5:06 PMIntl.DateTimeFormat
, or Intl related apis in generalRick Goodrow
07/11/2024, 5:12 PMerictgrubaugh
07/11/2024, 5:12 PMmoment
is my go-to lib for dates, and this is as simple as moment.months()
which gives you locale-specific month namesRick Goodrow
07/11/2024, 5:13 PMRick Goodrow
07/11/2024, 5:15 PMerictgrubaugh
07/11/2024, 5:17 PMshea brennan
07/11/2024, 5:45 PMRick Goodrow
07/11/2024, 5:45 PMIntl
library, which when running inside SuiteScript wouldn't work. I could be wrong though.battk
07/11/2024, 5:46 PMRick Goodrow
07/11/2024, 5:46 PMshea brennan
07/11/2024, 5:46 PMbattk
07/11/2024, 5:47 PMbattk
07/11/2024, 5:48 PMRick Goodrow
07/11/2024, 5:49 PM