gpt4 book ai didi

javascript - 从日期字符串获取日期

转载 作者:行者123 更新时间:2023-12-02 15:59:29 29 4
gpt4 key购买 nike

如何从 JavaScript 中的日期字符串获取日期?

Output:
2015-06-25 - Thursday
2015-07-10 - Friday

最佳答案

你可以试试这个:

var d = new Date("2015-06-25");
var weekday = [];
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";

var day = weekday[d.getDay()]; // Wednesday

关于javascript - 从日期字符串获取日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31325455/

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