Is there any way via HTML5, proprietary apis, or PhoneGap to obtain the date format a given user is likely to want?
I currently display everything as MM/dd/yyyy
, but this is confusing for any users who live in dd/MM/yyyy
countries.
Is there any way via HTML5, proprietary apis, or PhoneGap to obtain the date format a given user is likely to want?
I currently display everything as MM/dd/yyyy
, but this is confusing for any users who live in dd/MM/yyyy
countries.
I believe you will want to look into the Globalization plugin's getDatePattern method.
https://github.com/phonegap/phonegap-plugins/tree/master/Android/Globalization https://github.com/phonegap/phonegap-plugins/tree/master/BlackBerry/Globalization https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/Globalization
The simplest way to determine the local day-month/month-day order is to check it.
You can check once and save it as a boolean to use in any input or output date formatting.
(this returns true if the date should precede the month- feel free to reverse it!).
Date.datefirst= (function(){
return Date.parse('2/6/2009')> Date.parse('6/2/2009');
})()