|
-
Mar 31st, 2008, 09:45 AM
#1
Thread Starter
Addicted Member
[RESOLVED] [2008] Parse XML style date and time
Hello,
I've been struggling with this all afternoon, and everything I find on Google seems to talk about converting dates and times TO the format I've already got.
I have an XML file which has recorded a date and time of:
2009-03-28T16:24:22+00:00
What I want to know is how I convert it to dd/MM/yyyy.
In my despiration, I've started working with substrings to break it up and re-assemble it again, but there has got to be a better way.
One of the latest things I've tried is:
Code:
strDate = strDate.Substring(0, 10)
Dim dteDate As DateTime = DateTime.ParseExact(strDate, "yyyy-MM-dd", New Globalization.CultureInfo("en-GB"))
... but this complains that The DateTime represented by the string is not supported in calendar System.Globalization.GregorianCalendar.
Convert.ToDateTime(strDate) doesn't seem to want to play either.
-
Mar 31st, 2008, 10:12 AM
#2
Re: [2008] Parse XML style date and time
Try this
Code:
Dim s As String = "2009-03-28T16:24:22+00:00"
Dim d As Date = Date.ParseExact(s, "yyyy-MM-dd'T'HH:mm:sszzz", Nothing)
MsgBox(d.ToString)
-
Mar 31st, 2008, 10:27 AM
#3
Thread Starter
Addicted Member
Re: [2008] Parse XML style date and time
Many thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|