Click here to Skip to main content
11,715,022 members (73,507 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 11:11am
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 530
1 Richard MacCutchan 275
2 Maciej Los 259
3 ManasKumarM 155
4 Frankie-C 125
0 Sergey Alexandrovich Kryukov 775
1 CHill60 415
2 Richard MacCutchan 405
3 Maciej Los 389
4 OriginalGriff 320


Advertise | Privacy | Mobile
Web03 | 2.8.150901.1 | 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