ios 中时间格式转换出错
h5页面在ios中的时间、日期乱码问题,是因为数据库传给前端时,中间含有T和-,而ios不支持含有特殊符号的T和-,需要把T替换为空格,将-替换为/,然后自己再拼成要展示的格式情况
if (str != undefined && str != "" && str != null) {
if (str.toString().indexOf('T') != -1) {
//str = new Date(str).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, ''); ///去掉日期中的T
str = str.replace(/T/g, ' ').replace(/\.[\d]{3}Z/, ''); ///去掉日期中的T
}
str = str.replace(/-/g, "/"); //将-替换为/,因为ios中不支持-和T