Get a substring of a string

PHOTO EMBED

Thu Jun 17 2021 11:04:08 GMT+0000 (Coordinated Universal Time)

Saved by @hisam #javascript #strings #substring #lastindexof

const date = '2021-06-14T08:29:40.886+00:00'
const formattedDate = date.substring(0,date.lastIndexOf('T'))
console.log(formattedDate)

// prints: "2021-06-14"
content_copyCOPY