Javascript - Retrieve OS Date formatting -
hmmm... okay i've been searching web 2 days without luck. i've seen lot of answers on how format javascript date example new date().tostring("yyyy-mm-dd")... return 2013-04-05.
this absolutely not problem.
what want, possibility set format in os displays dates, retrieve specific format , display in browser.
for example, let's changed format of date in os mm-yyyy/dd (this arguement sakes, whether work or not irrelevant)). i'd expect see 04-2013/05 in os, right? next want retrieve specific format in browser via javascript can use format dates throughout webpage.
if lunacy , cannot done, please tell me, i've got headache searching. also, if use somedateobject.tolocaledatestring() without explaining why .tolocaledatestring work, i'm going ignore it, because i've tried setting date-format in os numerous formats , every single time use .tolocaledatestring(), receive same format: dd/mm/yyyy
first attribute of .tolocaledatestring method locale(s) used.
current locale can obtain through navigator.language (in firefox or chrome) parameter. in ie can obtain navigator.browserlanguage or navigator.systemlanguage
in browsers other ie impossible obtain system language way
after can call new date.tolocalestring(navigator.language||navigator.browserlanguage) , formated correctly depending on browser language
Comments
Post a Comment