扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
Public Function IsRunnian(ByVal n As Integer) As Boolean
成都创新互联公司主营西丰网站建设的网络公司,主营网站建设方案,重庆App定制开发,西丰h5重庆小程序开发搭建,西丰网站营销推广欢迎西丰等地区企业咨询
Dim res As Boolean
res = False
If n Mod 400 = 0 Then
res = True
End If
If (n Mod 100 0) And (n Mod 4 = 0) Then
res = True
End If
IsRunnian = res
End Function
Public Function Fc(ByVal td As Date) As Byte
Dim y As Integer
Dim m As Integer
Dim d As Integer
Dim yc As Integer
Dim mc As Integer
Dim dc As Integer
y = Year(td)
m = Month(td)
d = Day(td)
dc = d
If IsRunnian(y) Then
mc = Val(Mid("512503514624", m, 1))
Else
mc = Val(Mid("622503514624", m, 1))
End If
yc = ((y Mod 100) \ 4 + (y Mod 100)) Mod 7
Fc = (yc + mc + dc) Mod 7
End Function
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);
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), "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日")
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的你,应该懂的。
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流