Reputation: 635
When using message.createdAt, it returns a huge string of information about the time a message was send.
Example output: Sat Aug 01 2020 12:23:56 GMT+0200 (Central European Summer Time)
Is there a way to shorten this huge info into just: Sat Aug 01 2020 12:23:56
?
I thought of splitting it by " " and then concat the first 5 elements of the array, is there a better idea than:
const time = msg.createdAt.toString();
const time_array = time.split(" ");
const time_str = time_array.reduce((sum, element) => sum+element);
Upvotes: 1
Views: 2766