How does js elegantly concatenate the date of time 1 and the time of time 2?

my way is to use toLocaleDateString (), to get the string form of time 1 2018,). Gettime () 4 and 28, and then bring it into new date (2018-4-28

then string 2 also gets the time, of the date

then subtract the time of the date of string 2 from the time of string 2 to get the time of string 2 time

add this time to the time of the string 1 date, and then bring the time into new date () to get the time after splicing.

but it feels complicated

Mar.06,2021

what? It's complicated. I don't understand what you're talking about


Date object has a method to obtain the time of year, month, day and day directly, which can be used directly
getFullYear ()
getMonth ()
getDay ()
getHours ()
getHours ()
getMinutes ()

function getConcatTime(date1, date2) {
    return date1.getFullYear() + '/' + date1.getMonth() + '/' + date1.getDay() + ' ' + date2.getHours() + ':' +  date2.getMinutes()  + ':' + date2.getSeconds()
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3606b-2bff4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3606b-2bff4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?