Issue to get current time format from system using c# -
string dateformate = cultureinfo.currentculture.datetimeformat.shortdatepattern; with above code can current system date format whenever change date format in system.
ex: if change date format yy/mm/dd. can same format result. can't correct current time format. if set date format hh:mm tt in system, getting format h:mm tt.
string timeformate = cultureinfo.currentculture.datetimeformat.shorttimepattern; the following image showing can change system date , time format.

try
datetime result; if (datetime.tryparse("31/1/2010", system.globalization.cultureinfo.getcultureinfo("en-gb"), system.globalization.datetimestyles.none, out result)) messagebox.show(result.toshortdatestring()); else messagebox.show("not in great britain format"); change en-gb ot en-us. if want make change permanant running appdomain, assign system.globalization.cultureinfo.currentculture getculture of en-us
following code return shortdateformat in computer
messagebox.show(globalization.cultureinfo.currentculture.datetimeformat.shortdatepattern) not tried , reference
ref: http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.datetimeformat.aspx
use following link lcids identifying cultures: http://msdn.microsoft.com/en-us/library/0h88fahh(vs.85).aspx
thanks
Comments
Post a Comment