View Full Version : Need help for Date format

23 Jun 2010, 4:47 AM

I have one typical requirement in project.

I have two DateField in a form. Now, as per requirement, it should accept date format according to the county in which site opened. It means if User is from India, it should accept dd/mm/yyyy format, if it is from US, it should accept yyyy/mm/dd etc. (This is just an example).

Hope, I am clear with my requirement.

Please let me know about any hint or other way to achieve this.


23 Jun 2010, 5:00 AM
So you want dynamic localization (http://www.sencha.com/deploy/dev/examples/locale/multi-lang.html)?

23 Jun 2010, 5:12 AM
yes...I want it.

I have seen the examples in which we have to select language but I want to make it more dynamic. It should automatically recognize county and set format of date.

23 Jun 2010, 5:20 AM
You could try using HTML5 location support or use a server with an IP region database.

23 Jun 2010, 6:04 AM
Can you more focus on HTML5 location support or give some example?

23 Jun 2010, 7:18 AM
Never used it myself (because it isn't supported on IE < 9).

You can find some info in a recent Ext blog post (http://www.sencha.com/blog/2010/06/09/the-html5-family-geolocation/).

23 Jun 2010, 7:37 AM
So it is use less for me also as not support by IE < 9. is there any alternative?

23 Jun 2010, 7:47 AM
You can use a GeoIP database on your server or make a request from the client to a GeoIP provider like freegeoip.net (which has a JSON interface that can be used with a ScriptTagProxy).

24 Jun 2010, 1:44 AM
Thanks a ton for reply.

I have one more issue with Datefield.

I have added DateField in my form with following code.

format: 'Y/m/d',
altFormats: 'Y/n/d|Y/n/j|Y/m/j|Y/m|Y/n|Y|Y/m/d',
vtype: 'SearchDateFormat',
validationEvent: false

As shown above, I have mentioned so many formats for field which user can enter.
My problem is when user enter 2008 in field and press tab (blur event), it automatically
convert it into 2008/[current month]/[current date].

But, I want that if user enter date using any formats mentioned, it should not change. How, can I prevent it to happen?

Hope, I am clear.

Thanks in advance

24 Jun 2010, 1:52 AM
Could you localize based on the passed Accept-Language header if all other methods are unavailable?

eg, my FF sends:

Accept-Language: en-gb,en;q=0.5

But a user in the US would have his browser configured to pass

Accept-Language: en-us,en;q=0.5