Skip to content

How to concat date string to another string using ‘=>’

string1 = "Incident is created";
string2 = "2020-08-01T02:00:45.000Z"

I want to concat both the strings so that final output looks as below:

2020-08-01=>Incident is created

I am doing string1.concat(string2) but it is not giving the desired output.



You can simply and the easiest way is to use concat and split()

let string1 = "Incident is created";
let string2 = "2020-08-01T02:00:45.000Z"
let string3 = '=>'

let concat = string2.split('T')[0].concat(string3, string1);

console.log(concat) //2020-08-01=>Incident is created
User contributions licensed under: CC BY-SA
9 People found this is helpful