重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
Label1.Text = "12时演示:" + Now.ToString("yyyy-MM-dd hh:mm:ss")
网站建设哪家好,找成都创新互联!专注于网页设计、网站建设、微信开发、小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了舒城免费建站欢迎大家使用!
Label2.Text = "24时演示:" + Now.ToString("yyyy-MM-dd HH:mm:ss")
Label3.Text = "UTC时演示:" + System.DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss")
Label4.Text = "时间为不补0:" + Now.ToString("yyyy-MM-dd H:m:s")
Label5.Text = "时间戳:" + CLng(System.DateTime.UtcNow.Subtract(New Date(1970, 1, 1, 0, 0, 0)).TotalMilliseconds).ToString
Dim w As String
If Now.DayOfWeek = DayOfWeek.Sunday Then
w = "天"
ElseIf Now.DayOfWeek = DayOfWeek.Monday Then
w = "一"
ElseIf Now.DayOfWeek = DayOfWeek.Tuesday Then
w = "二"
ElseIf Now.DayOfWeek = DayOfWeek.Wednesday Then
w = "三"
ElseIf Now.DayOfWeek = DayOfWeek.Thursday Then
w = "四"
ElseIf Now.DayOfWeek = DayOfWeek.Friday Then
w = "五"
Else
w = "六"
End If
Label1.Text = (Format(Now.Year "年" Now.Month "月" Now.Day "日" " " "星期" w " " Now.Hour ":" Now.Minute ":" Now.Second))
End Sub
定时器中处理
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 10 '10毫秒刷新一次
Timer1.Start() '开启定时器
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = Now
End Sub
将datePicker设置为该日期,这样就可以确保每次从nib中加载此视图时,选取器都会重置为当前得日期和时间就可以了。
设计界面双击那个按钮(自动跳到代码里)
然后输入 要显示时间的那个Label.Text = DateTime.Now.ToString()
this.Label1.Text = DateTime.Now.Hour.ToString() + "时" + DateTime.Now.Minute.ToString() + "分" + DateTime.Now.Second.ToString() + "秒";