Concatenate date and time in a variable

0

I need to create a complete date with date and time, I have two functions that receive a date and another time and I want to concatenate them to show the following format: yyyy-MM-dd HH:mm:ss

dateChange(selectedDate) {
   //console.log(selectedDate);
   const date = '${selectedDate.year}-${selectedDate.month}-${selectedDate.day}';
   console.log(this.data);}
}

onChange() {
   console.log(this.hourTime);
}
    
asked by charli 17.10.2018 в 13:40
source

1 answer

0

Why do not you use the pipes? In the .html file you can do the following; {{ dateObj | date:'medium' }} and the output is // output is 'Jun 15, 2015, 9:43:11 PM'

You can also play with the dates from the .ts but it's simpler using the pipes Take a look at the documentation on the pipes:

  

link

    
answered by 17.10.2018 в 16:35