我正在尝试使用Moment.js在两个日期之间创建一个日期数组 以下工作在我的电脑上,但不适用于我的iphone或ipad(设备抓取)。 如果我将stopDate更改为2016-09-24或更低版本,则可以在我的设备上使用
var arr=[];
var startDate = moment("2016-06-01")
var stopDate=moment("2016-09-29")
while (startDate.isBefore(stopDate)) {
arr.push( moment(startDate).format('YYYY-MM-DD') )
startDate = moment(startDate).add(1, 'days');
}
alert(arr)
答案 0 :(得分:0)
这对我有用。 https://jsfiddle.net/stevenkaspar/mLwjdzey/
<script>
var arr = [];
var startDate = moment("2016-06-01");
var stopDate = moment("2016-09-29");
while (startDate.isBefore(stopDate)) {
arr.push( startDate.format('YYYY-MM-DD') );
startDate.add(1, 'days');
}
console.log(arr);
</script>
答案 1 :(得分:0)
以下代码将为您提供所有日期(包括):
MainForm mf = new MainForm();
string[] command = Text.Split(' ');
command[0] = command[0].ToLower();
if(textBox3.Text.Contains("blacklist"))
{
string Username = Text.Remove(0, command[0].Length + command[1].Length + 2);
using (TextWriter tw = File.CreateText(mf.Database + "\\" + mf.BlackList + "\\" + command[1] + ".txt"))
{
tw.Write(command[2].ToString());
messagesChat.Text += command[1] + " was added in BlackList!";
}
}