jquery - 如何使用 jquery 将“2020-10-08 09:38:08”转换为 2020 年 3 月格式
问题描述
$.datepicker.formatDate('M dd', date)
我已经尝试过了,但它给了我错误
jquery-ui.js:8924 Uncaught TypeError: date.getDate is not a function
解决方案
该formatDate
方法需要一个Date
实例。
如果您从该特定字符串开始,您可以轻松地将其转换为 ISO 8601 格式,然后将其解析为Date
实例
const date = "2020-10-08 09:38:08"
const dateInstance = new Date(date.replace(" ", "T"))
const formatted = $.datepicker.formatDate('M dd', dateInstance)
推荐阅读
- c# - 起订量返回零结果
- python - 如何校正 Y_labels 图像的形状
- jupyter-notebook - 如何在谷歌计算引擎(深度学习 VM)上的 conda 环境中运行 jupyter lab?
- python - 如何使用 Python Telebot 发送多行文本
- javascript - 网页(在 php 中),即 Javascript websocket 客户端未连接到 Python Websocket Server
- android - 如何更改 Android Studio 终端键映射
- sql - 在每个类别中选择前 N 个最常购买的商品
- angular - 如何在 Angular 中管理大量类似的响应式表单
- c# - 在 C# 中使用 OpenXML Power Tool 数据透视表
- php - 不断收到此错误-不正确的整数值:'' for column 'poi_id' at row 1 )