gpt4 book ai didi

javascript - 从 2015-08-01 获取来自日历的 Day "Thursday"

转载 作者:行者123 更新时间:2023-11-30 17:06:47 24 4
gpt4 key购买 nike

friend 们,我有一个输入字段,我在其中显示了日期选择器日历,它正在显示并且工作正常。文本字段字段日期,如 2015-08-01。我想要这个日期,我也想从这个日期开始,比如“星期四”,我希望你明白我的意思。当我点击日历中的任何日期时,它会在输入字段中显示类似 2015-08-01 的日期,我使用更改并保存在变量中来获取此字段,然后我尝试从中获取日期但失败了。这是我尝试的代码

 var d = new Date();
var n = String(d.getDay());
alert(n);

还有这个

var d = new Date();
var days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
alert( days[d.getDay()] ) ;

最佳答案

尝试这段代码希望这有效HTML

<p>Date: <input type="text" id="datepicker"></p>

JavaScript

$( "#datepicker" ).datepicker( {
onSelect: function(dateText, inst) {
var date = $(this).val();
var d = new Date(date+" UTC");
alert(days[d.getDay()]);
}
});
var days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];

js fiddle Click

关于javascript - 从 2015-08-01 获取来自日历的 Day "Thursday",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27842802/

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