Converting E MMM dd HH: mm: ss Z yyyy for dd / MM / yyyy HH: mm: ss c #

0

I am getting the following date Thu Sep 01 00:00:00 BRT 2016 and need to convert to dd/MM/yyyy HH:mm:ss

Only convert generates error, I am receiving this date via string of a System.

Can anyone help me?

DateTime dtPeca;
dtPeca = Convert.ToDateTime(linha[4]);
    
asked by anonymous 29.11.2017 / 15:55

1 answer

1

If you are sure that the format will always be the same, you can do the conversion using TryParseExact

DateTime dateValue;
DateTime.TryParseExact(data, "ddd MMM dd hh:mm:ss BRT yyyy", new CultureInfo("en-US"), 
                       DateTimeStyles.None, out dateValue);
    
29.11.2017 / 16:03