-6

I got this kind of timestamp by parsing TCP packet 'Jan 27, 2017 16:58:15.688856000 India Standard Time'. How to convert this string to Datetime in C#?

3
  • Use Split to get parts, and then analize them Commented Jan 31, 2017 at 4:58
  • splitting the string and parsing i can do.. is there any parseExact format (or) IFormatProvider for this kind of DateTime? Commented Jan 31, 2017 at 5:00
  • Well...No. For that string no. But you can use RegEx with enums to simplify Commented Jan 31, 2017 at 5:07

2 Answers 2

0

use cliver

    DateTime dt=new DateTime
    if (!Cliver.DateTimeRoutines.TryParseDate('your text', Cliver.DateTimeRoutines.DateTimeFormat.UK_DATE, out dt))
    {
        //show message
    }
Sign up to request clarification or add additional context in comments.

2 Comments

Timestamp Format is specific like UK_Date.. It can be any thing.. How can i convert to generic UTC format?
look at below answer or look at link1,link2
0

According to this link you can simply try

string iString = "Jan 27, 2017 16:58:15.688856000 India Standard Time";
DateTime oDate = DateTime.ParseExact(iString, "MM-dd-yyyy HH:mm tt",null);

or

DateTime oDate = DateTime.ParseExact(iString, "MM-dd-yyyy",null);

After that if you want to format your own way you can try this link like

2017/02/01 or May 07, 2016

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.