Click here to Skip to main content
11,413,961 members (77,016 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
I have been working on this application that reads a file and gets infromation on software. The output is 2011-10-20T20:49:59-0400 and I need to get the string to look like this Oct 20, 2011 20:49:59

I can split the 2 at the t with the code below but i cant get the output i want and need some help.

Dim str As String
Dim strArr() As String
Dim count As Integer
str = INSTDATE
strArr = str.Split("T")
For count = 0 To strArr.Length - 2
    INSTDATE = (strArr(count))
Next
Posted 24-Mar-12 12:11pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
SAKryukov at 24-Mar-12 18:15pm
   
In principle, enough, a 5.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hello

try this:

Dim str As String = Nothing
Dim strArr As String() = Nothing
str = "2011-10-20T20:49:59-0400"
strArr = str.Split("T")
 
Dim converted As String = String.Format("{0} {1}", DateTime.Parse(strArr(0)).ToString("MMMM-dd-yyyy"), strArr(1))

Of course, it's better to use TryParse instead of Pars and handle unknown formats.
  Permalink  
v5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Use this code:

INSTDATE.ToString("MMM dd,yyyy HH:mm:ss")
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,035
1 OriginalGriff 7,387
2 Maciej Los 3,640
3 Abhinav S 3,298
4 Peter Leow 3,084


Advertise | Privacy | Mobile
Web01 | 2.8.150427.2 | Last Updated 24 Mar 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100