大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
VB内置的Weekday函数就可以返回星期.
创新互联服务项目包括宝鸡网站建设、宝鸡网站制作、宝鸡网页制作以及宝鸡网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,宝鸡网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到宝鸡省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
Weekday(date[, firstdayofweek])
-- date: 必要; Date类型; 要求的日期
-- firstdayofweek: 可选; vbDayOfWeek类型; 定义每周第一天(默认为星期天)
Weekday返回一个Integer, 代表每周第几天.
============================================
WeekdayName(weekday[, abbreviate][, firstdayofweek])
-- weekday: 必要; Long类型; 每周第几天
-- abbreviate: 可选; Boolean类型; 表示星期的名称是否被缩写(默认为False)
-- firstdayofweek: 可选; vbDayOfWeek类型; 定义每周第一天(默认为星期天)
WeekdayName返回一个String, 如"星期一", 但根据不同的系统, 也会返回如"Monday".
============================================
你也可以不用WeekdayName自己得到星期名
Choose(Weekday(#8/8/2008#, vbMonday), "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日")
1
string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
string week = Day[Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d"))].ToString();
this.lbDay.Text = week;
2
this.lbDay.Text = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek);
Dim ThisDay As String = Format(Now, "yyyy-MM-dd") '获得当前日期字符串
Dim ThisDateTime As DateTime = Convert.ToDateTime(ThisDay) '当前日期转换成DateTime
Dim ThisWeekDay As Integer = ThisDateTime.DayOfWeek '获得当前日期是星期几
Dim differadd As Integer = 1 - ThisWeekDay '相差的天数(星期1与当前星期几相差的天数)
Dim MyAdd As New TimeSpan(differadd, 0, 0, 0)
Dim MyYear As Integer = Format(Now, "yyyy") '获取当前日期的年份
Dim MyMonth As Integer = Format(Now, "MM") '获取当前日期的月份
Dim MyDay As Integer = Format(Now, "dd") '获取当前日期是几号
Dim MyToday As DateTime = New DateTime(MyYear, MyMonth, MyDay)
Dim Yourday As DateTime = MyToday.Add(MyAdd)
MsgBox("本周星期一的日期是:" Yourday)
C#
string [] Day=new string []{"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
Console.WriteLine(Day[Convert.ToInt16(DateTime.Now.DayOfWeek)]);
相信VB.net的你,应该懂的。