How can pure digital String be converted into time?

"20190116100359" converted to 2019-01-16 10:03:59 is this pure String or Int type how to convert to date
download several date types of plug-ins are not ideal. Pure numeric format time is not supported. All returns are false

Apr.26,2022

moment (or luxon)

moment("20190116100359","YYYYMMDDHHmmss").format("YYYY/MM/DD HH:mm:ss")

any format can be converted


moment.js ( https://momentjs.com/)


casually wrote one, because there is no time to verify outside, the general idea should meet your needs

const timeStr = "20190116100359"

const time = timeFormat(timeStr, 'CCCC/CC/CC CC:CC:CC')

function timeFormat(time, format) {
    const timeStr = String(time)
    let index = 0
    let retDate = '' 
    for(let i = 0, l = format.length; i < l; i PP) {
        if (format[i] === 'C') {
            retDate += timeStr[indexPP]
        } else {
            retDate += format[i]
        }
    }

    return retDate
}
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-1b35e80-3439a.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-1b35e80-3439a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?