本地存储返回无效的日期格式

编程入门 行业动态 更新时间:2024-10-24 23:27:27
本文介绍了本地存储返回无效的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

$ localStorage.doctorDateTime.push({ fullDate: new 日期(doctorDateTime)});

我在新日期中传递了日期字符串然后将其保存到本地存储但是当我从本地存储它显示我这种格式: 2015-01-01T13:41:18.300Z 如果是console.log(doctorDateTime) 。它显示正确的日期字符串

解决方案

localStorage.doctorDateTime.push({ fullDate: new 日期(doctorDateTime)});

我在新日期传递了日期字符串然后将它保存到本地存储,但是当我从本地存储中检索它时,它显示我这种格式: 2015-01-01T13:41:18.300Z $如果是console.log(doctorDateTime),则b $ b。它显示正确的日期字符串

此格式是有效的UTC格式。 您可以将其转换为任何格式并相应地使用。 Date.Parse 可用于此任务 - developer.mozilla/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse [ ^ ]

$localStorage.doctorDateTime.push({ fullDate : new Date(doctorDateTime) });

I passed date string in new Date and then save it to local storage but when i retrieve it from local storage it showing me this format: 2015-01-01T13:41:18.300Z while if console.log(doctorDateTime). it is showing right date string

解决方案

localStorage.doctorDateTime.push({ fullDate : new Date(doctorDateTime) });

I passed date string in new Date and then save it to local storage but when i retrieve it from local storage it showing me this format: 2015-01-01T13:41:18.300Z while if console.log(doctorDateTime). it is showing right date string

This format is a valid UTC format. You can convert it into any format and use accordingly. Date.Parse can be used for this task - developer.mozilla/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse[^].

更多推荐

本地存储返回无效的日期格式

本文发布于:2023-10-23 00:05:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519140.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   格式

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!