Js intercepts the string to get the desired character?

21:21:21 on 2018-07-03 I want to take this string 03 and 21:21:21 and store it in other variables

I tried to use the rules, but I couldn"t get it out of the rules, so I had to ask for help

.
Mar.25,2021

var str="2018/07/03 21:21:21"
console.log(str.split(" ")[1])//21:21:21
console.log(str.split(" ")[0].split("/")[2])//03

this is date data, which can be extracted by formatting it as a time type data without regular expressions. And it is more accurate to deal with it, and it is more convenient to use numbers later.


  

it's safer to convert to time processing

Menu