Hey! A question regarding dates and `format.format...
# suitescript
e
Hey! A question regarding dates and
format.format
. If my user preferences has the date format
MM/DD/YYYY
and I do the following, shouldn't the date become
07/17/2024
? At the moment the output is the same as the input.
Copy code
const currentDate = format.format({
        value: "2024-07-17",
        type: format.Type.DATE,
      })
b
"2024-07-17" is not a Date, its a string
if format.format fails its conversion, then it outputs the input, which is terrible error handling
e
Ah, yes. That's true, thanks. Another question though, how come the output of
format.format
when using
format.Type.DATE
includes the time? Is it possible to omit that somehow?
r
@Geoff at @battk suggestion, I've switched to using moment for any type of output (or manipulation) as I have much greater control. Only time I use N/format for dates anymore is when I need to pass them as parameter to something else NetSuite related.
b
it doesnt include the time, you are still using it wrong
e
You're right again, thanks 👍