2013-08-30 171 views
0

我這裏有一個工作代碼,但輸出是24小時格式:VB.net實時同步時鐘

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
Timer1.Enabled = True 
End Sub 

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick 
Label1.Text = Now.TimeOfDay.ToString() 
End Sub 

我用了一個定時器,但我的輸出是這樣的:

17:00: 30.123456

我希望我的輸出是這樣的12小時格式:

下午5點00

回答

0

我已經解決了這裏是我的12小時格式代碼:

Label1.Text = Date.Now.ToString("h:mm:ss tt")