2009-11-20 24 views

回答

4

VB.NET

' Assume the current culture is en-US. 
' The date is Feburary 16, 1992, 12 hours, 15 minutes and 12 seconds. 
Dim myDateTimeValue As String = "2/16/1992 12:15:12" 
Dim myDateTime As DateTime = DateTime.Parse(myDateTimeValue) 

' Reverse month and day to conform to a different culture. 
' The date is Feburary 16, 1992, 12 hours, 15 minutes and 12 seconds. 
Dim cultureGB = New CultureInfo("en-GB", True) 
Dim myDateTimeValue As String = "16/2/1992 12:15:12" 
Dim myDateTime As DateTime = DateTime.Parse(myDateTimeValue, cultureGB) 

' Dsiplay the date in DD/MM/YYYY format 
Debug.Print Format(myDateTime ,"dd/MM/yyyy") 

參考:http://msdn.microsoft.com/en-us/library/1k1skd40(VS.80).aspx

VB6

dim dt as date 
dim s as string 
s="10/09/2009" 
dt = cdate(s) 
+0

謝謝!如果我的日期是歐洲格式? dd/mm/aaaa – simone 2009-11-20 16:11:13

+0

但是,如果我嘗試打印myDateTime是美國格式...我怎樣才能打印它(並插入數據庫)在歐洲格式?謝謝 – simone 2009-11-20 16:27:44

+0

爲您添加了詳細信息 – Martin 2009-11-20 17:12:59

相關問題