Getting local date and time in desired format

hi,
i am using cocos creator ver 2.3.3. and i am trying to get the local time in the format:
Oct 21, 17:45
how can i do that? note that getLocaleXXX don’t work on ver 2.3.3.
thanks!

1 Like

What about format that string by yourself?
const months = ['Jan', 'Feb', ...];

try this code

const myDate = new Date();
const monthsList = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];

const formatedDate = `${monthsList[myDate.getMonth()]} ${myDate.getDate()}, ${myDate.toLocaleTimeString('en-US', {hour: 'numeric', minute: 'numeric', hour12: false})}`