This question already has answers here:
How to get the day of the week from the day number in Javascript?
                            
                                (5个答案)
                            
                    
                4年前关闭。
        

    

如何从日期字符串获取日期在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/

10-12 15:29