WizardsSleeve
WizardsSleeve

Reputation: 195

DateTime And ParseExact Problems

Hi There I wish to convert my string in format dd/mm/yyyy hh:mm:ss to a DateTime of the same format.

Dim ukCulture As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-GB")
Dim myDateTime As DateTime
myDateTime = DateTime.ParseExact("18/05/2010 23:42:10, "dd/MM/yyyy HH:mm:ss", ukCulture)

When I step through this code the variable myDateTime is 05/18/2010 23:42:10 it appears that the dd/mm is the wrong way around and I cant work out how to correct this. Can ayone offer any guidance on how to correct this please?

Upvotes: 1

Views: 760

Answers (2)

shmandor
shmandor

Reputation: 891

may be you should review your web.config and add section

globalization culture="en-GB"

Upvotes: 0

David M
David M

Reputation: 72890

The visualiser you are using to inspect the value of the datetime variable is rendering it in US format. The value stored is the actual date and time, and is correct. It's purely a visualisation problem - the code is working. You can format the datetime value to anything you want for your purposes if you need it as a string.

Upvotes: 2

Related Questions