gpt4 book ai didi

javascript - 将日期字符串格式化为日期

转载 作者:行者123 更新时间:2023-12-02 23:28:01 25 4
gpt4 key购买 nike

我想使用 moment 库格式化字符串 Date "14/06/2019 12:52" 以便操作 Date 对象而不是字符串。

我尝试使用 moment 库,但没有成功获得 Date 对象

const myDate = moment('14-06-2019 12:52')

const myDate 不是 Date 类型。

最佳答案

您还需要提供格式

const myDate = moment('14-06-2019 12:52', 'DD-MM-YYYY hh:mm');

关于javascript - 将日期字符串格式化为日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56643582/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com