.net - Convert.ToDateTime In C# From Specific Date String -
i have specific date string
: "13/02/07,16:05:13+00"
i trying convert in c#
datetime
(convert.todatetime
) maintain receiving errors.
i have tried parse using next code no avail:
datetime dt = datetime.parseexact(date, "yy/mm/dd,hh:mm:ss+00",system.globalization.cultureinfo.currentculture);
how convert string
datetime
specific datetime
string
.
don't utilize currentculture
- utilize invariant culture. otherwise you'll picking current culture's date , time separators.
also, need utilize hh
instead of hh
you're using 24-hour clock, not 12-hour clock. works fine:
using system; using system.collections.generic; using system.globalization; class test { static void main() { string date = "13/02/07,16:05:13+00"; datetime dt = datetime.parseexact(date, "yy/mm/dd,hh:mm:ss+00", cultureinfo.invariantculture); console.writeline(dt); } }
is "+00" going same? if need cope non-zero offsets, alter things bit.
c# .net .net-3.5
No comments:
Post a Comment