Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello!

 

I looked in MSDN help but I couldn't understand how to convert String to DateTime. To be specific i have string "2003:10:31 22:34:52" and I need to convert it to DateTime object. How to do this? Please help.

 

Best regards,

Water

Posted
Yes, but in my case date is not separated by "/". This is not problem, I will write some function to convert, but I ask for later purpose. Is it possible to say Format = "yyyy/dd/mm hh:ss" and to pass this to convert function?
  • *Gurus*
Posted
Dim dateTime As DateTime
Dim dateTimeFormat() As String = {"yyyy/dd/MM hh:mm:ss", "yyyy/dd/MM h:m:s"}
Dim dateTimeString As String = "2004/05/01 5:55:00"
dateTime = dateTime.ParseExact(dateTimeString, dateTimeFormat, System.Globalization.CultureInfo.InvariantCulture, Globalization.DateTimeStyles.None)
MessageBox.Show(dateTime.ToString("F"), String.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...