NOTION 정리/Javascript

IOS 사파리에서 Date가 NaN으로 나올 때

dev_sr 2023. 11. 3. 15:44

 

function convert( date ){
    var element, dayElement, endTime, hours, mins, msLeft, time, day;

    var arr = date.split(/[- :]/);
    date = new Date(arr[0], arr[1]-1, arr[2], arr[3], arr[4], arr[5]);
}

 

사파리에서 Y-m-d H:i:s 포멧을 지원하지 않아서 발생(21년 7월에 확인)

Y-m-d H:i:s  포멧으로 date 정보를 받을 경우 split 으로 분해해서 새로운 date로 생성하면 해결됨

 

 

 

https://stackoverflow.com/questions/26657353/date-on-ios-device-returns-nan

 

Date on iOS device returns NaN

i'm currently developing a cordova web based application with ionic and angularjs. now i've created a service that returns a formatted time the way my client wants it.. the problem with this is that

stackoverflow.com