I have a date string formatted as:
20250330230300-0400
I am trying to get that string into the format of:
3/30/2025 11:03
What I was originally doing was something like this:
var formattedDateTime = dateString.substring(4,6) + '/' + dateString.substring(6,8) + '/' + dateString.substring(0,4) + ' ' + dateString.substring(8,10) + ':' + dateString.substring(10,12)
//Remove leading 0s from day and month
formattedDateTime = formattedDateTime .replace(/0(d)/0?(d)/g, '$1/$2')
What my code does not account for is the 23 military time being 11:03 instead of 23:02. Can someone point me to either how to do this or a more efficient way of doing this?