Shridhar Salunkhe

Shridhar Salunkhe

  • NA
  • 294
  • 1.2k

get specific content from string

May 22 2017 3:57 AM
Mon May 22 2017 13:25:00 GMT+0530 (India Standard Time)
 
in this string want contents between "Mon" and "GMT"  and convert that string into datetime format.

Answers (2)

0
Mazhar Pasha

Mazhar Pasha

  • 0
  • 61
  • 2.1k
May 22 2017 8:01 AM

You're going to need to use DateTime.ParseExact:

var date = DateTime.ParseExact( "Mon Jan 13 2014 00:00:00 GMT+0000 (GMT Standard Time)", "ddd MMM dd yyyy HH:mm:ss 'GMT'K '(GMT Standard Time)'", CultureInfo.InvariantCulture);

after parsing the date you can then send it out your way:

date.ToString("yyyy-MM-dd");
0
Dharmraj Thakur

Dharmraj Thakur

  • 236
  • 7.7k
  • 710k
May 22 2017 4:55 AM
You can give format as per your requirement like this...
Convert.ToDateTime(yourString).toString("mm/dd/yyyy");