DateTime在VB.Net中更改日期值和设置特定的时间值



我有这个值,例如

Dim start_time As String = 12/30/1899 8:30:00 PM

然后我想把它改成

Dim final_start_time As String = 0000-00-00 20:30:00 ' i want to come up with this value

或者另一个例子是

   Dim start_time As String =  12/30/1899 10:30:00 AM

Dim final_start_time As String = 0000-00-00 10:30:00

根据你修改的问题,这里是一些代码。必要时进行修改。我用es-ES作为文化…实际上我不知道那是什么文化…但是在dateformat MSDN页面上,这似乎生成了你想要的格式…

Dim myOriginalDateTime As DateTime = Now
Dim mynewDateString As String = ""
Dim myFinalDateString As String = ""
Dim culture As New System.Globalization.CultureInfo("es-ES")
mynewDateString = myOriginalDateTime.ToString("G", culture)
Dim arrDateParts() As String = Split(mynewDateString, " ")
myFinalDateString = "0000-00-00 " & arrDateParts(1)
MsgBox(myFinalDateString)

试试这个链接:

http://msdn.microsoft.com/en-us/library/zdtaw1bw (v = vs.110) . aspx

:

http://msdn.microsoft.com/en-us/library/vstudio/az4se3k1 (v = vs.100) . aspx

使用.tostring方法,并指定一个格式

相关内容

  • 没有找到相关文章