ios date format bug

Generally, we are When page rendering time xxxx-xxxx, ios system, new Date (xxxx-xxxx) when will report NaN-NaN-NaN NaN: NaN abnormal, the time format xxxx-xxxx instead xxxx / xx / xx we can solve this problem. Using regular conversion:
/* 转换为时间戳 */
function formatTimeStamp(date){
    return Date.parse(new Date(date)) || Date.parse(new Date(date.replace(/-/g,'/')));
}
formatTimeStamp('2017-11-11');

 

Guess you like

Origin www.cnblogs.com/wkyuan/p/11316541.html