Format a date from ISO to string

I can’t figure this out. In the mongo shell I run this:

const d = new Date();
print(d);

I get
Thu Jul 30 2020 17:21:55 GMT-0500 (CDT)

I want
30-JUL-2020 17:21:55

how do you do this?

const d = new Date();
print(d.getMonth().toString() + ‘-’ + d.getDate().toString() + ‘-’ + d.getFullYear().toString() + ’ ’ + d.getHours().toString() + ‘:’ + d.getMinutes().toString() + ‘:’ + d.getSeconds().toString());
~

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.