How can I convert a Date object to string like this: "20140127T224000Z"
I have Date object selectedTime
When I do selectedTime.toISOString()
I get
"2018-10-18T16:00:00.000Z"
Then, I apply replace function:
var date = selectedTime.toISOString().replace('-','').replace(':','').replace('.','');
but it doesnt work for some reason, returns
I tried to add mo replace functions, but I still get the same result, for some reason, the "-" or the ":" are not removed
Using regex, doesnt work either
Here is the code snippet in typescript:
onTimeSelected(selectedTime: Date, events) {
var date = selectedTime.toISOString().replace('-','').replace('-','').replace(':','').replace(':','').replace('.','');
var redirectTo = 'https://calendar.google.com/calendar/r/eventedit?dates=' + date + '/' + date;
window.open(redirectTo, '_blank');
}
OK, I will keep it simple, how do you explain this: