|M| 大家都是如何取星期的日子的 谢谢
DateTime dt = DateTime.Now;
while (!(dt.DayOfWeek == System.DayOfWeek.Sunday))
{
dt = dt.AddDays(-1);
}
Response.Write( "这个星期时间为: " + dt.ToShortDateString() + "至 " + DateTime.Now.ToShortDateString());
Response.Write( " </br> ");
Response.Write( "这个星期时间为: " + dt.AddDays(-1).ToShortDateString() + "至 " + dt.AddDays(-7).ToShortDateString());
Response.Write( " </br> ");
上面是我取星期的不知道有没有更好的办法
[解决办法]
DateTime dt = DateTime.Now;
while (!(dt.DayOfWeek == System.DayOfWeek.Sunday))
{
dt = dt.AddDays(-1);
}
可以改为
DateTime dt = DateTime.Now;
dt = dt.AddDays(-(int)dt.DayOfWeek);
[解决办法]
或者
DateTime dt = DateTime.Now.AddDays(-(int)DateTime.Now.DayOfWeek);
[解决办法]
高手回答就是快哈!!!
[解决办法]
string dt = DateTime.Now.DayOfWeek.ToString();
switch (dt)
{
case "Monday ": dt = "星期一 "; break;
case "Tuesday ": dt = "星期二 "; break;
case "Wednesday ": dt = "星期三 "; break;
case "Thursday ": dt = "星期四 "; break;
case "Friday ": dt = "星期五 "; break;
case "Saturday ": dt = "星期六 "; break;
case "Sunday ": dt = "星期日 "; break;
}
Label1.Text = dt.ToString() ;
[解决办法]
- -!看来我理解错LZ的意思了
[解决办法]
http://www.cnblogs.com/antsoftcn/archive/2006/12/27/604737.html
[解决办法]
取当前周的日期?
计算今天是星期几,与周日相减进行计算
[解决办法]
看看吧,没什么说的了
[解决办法]
DateTime DT = DateTime.Now;
Console.Write(DT.AddDays(1-(int)DT.DayOfWeek).ToShortDateString() + DT.AddDays(7 - (int)DT.DayOfWeek).ToShortDateString());
[解决办法]
来晚了 只能学习下了
[解决办法]
学习