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.

enter image description here

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

ref: http://social.msdn.microsoft.com/forums/windows/en-us/01ecfe69-519f-400e-b08b-fa8979a7409e/how-to-detect-datetime-format-on-computer

use following link lcids identifying cultures: http://msdn.microsoft.com/en-us/library/0h88fahh(vs.85).aspx

thanks


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -