how to convert datetime in C#, please Convert this format 27/01/2016 08:00:17 to T,270116,040017 -
how convert datetime in c#? please convert format 27/01/2016 08:00:17 t,270116,040017, expected output - t,270116,040017 , datetime - 27/01/2016 08:00:17
use datetime.parseexact addhours, create custom formatting:
string dtstr = "27/01/2016 08:00:17"; datetime dt = datetime.parseexact(dtstr, "d/m/yyyy hh:mm:ss", cultureinfo.invariantculture); dt = dt.addhours(-4); string dtresult = dt.tostring("t,ddmmyy,hhmmss"); result:
t,270116,040017 note: datetime string format looks rather unusual. check this more info.
Comments
Post a Comment