• 0

[VB.NET] Time conversion problem


Question

Ok, I know I should know this after all these years, but I don't so...

We are getting an XML file from outside out world that has two times; StartTime and EndTime. The EndTime is a string (Xml - of course) that is "11:59:00PM" and when I run the following code it changes it's value to "11:00PM" What the????

Dim sItemEndTime As String = "11.59.00PM"

Dim dDate As System.DateTime

dDate = sItemEndTime

MessageBox.Show(dDate)

Any thoughts?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Its the "." that is no doubt causing the confusion, as your culture settings aren't set up to recognise the "." as a time separator.

On first run (console app in C#) I got 23:00:00 as my output

Before the next run, I set the Time separator under Control Panel to be the "." and this time I got 23.59.00.

What you could do is simply parse out the "." to make it a ":" (assuming thats your usual time separator) and everything should work as you expect it.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.