Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Posts: 18
Registered: ‎12-20-2010
My Device: bold
My Carrier: webmaster

working with html5 date input



I'm using html5 input date controler.

Depending on blackberry model, there is some diferences in display :


On a 9800 simulator :



on a 9700 simulator (in french)



on a 9700 (in english)



So is there anyway to manage the date format ?


In my code i'm doing:

var d=new Date(dat1.substr(6,4),dat1.substr(0,2),dat1.substr(3,2),0,0,0,0);


Depending on each model, I have to adapt my code ?


Thanks for your support,


Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: working with html5 date input

My guess is that the UI being displayed is based on the regional settings configured for the device and that you cannot change how the display looks from your code.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Posts: 18
Registered: ‎12-20-2010
My Device: bold
My Carrier: webmaster

Re: working with html5 date input

Thanks for your answer.

The display is not important. I need to process the date and compate 2 dates but the results are diferent in 9700 / 9800


There is my code


Page 1:


<input type="date" id="date2" name="date2" />

<input type="date" id="date3" name="date3" />



Page 2:

var oldUrl=location.href;
var newUrl=oldUrl.replace('local:///','local://');
var url = blackberry.utils.parseURL(newUrl);

var dat2=url.getURLParameter("date2");

var dat3=url.getURLParameter("date3");


var datefin2=new Date(dat2.substr(6,4),dat2.substr(0,2),dat2.substr(3,2),0,0,0,0);

var datefin3=new Date(dat3.substr(6,4),dat3.substr(0,2),dat3.substr(3,2),0,0,0,0);

->its not ok because the value depends on the format

ex : in 9700 I have DD/MM/YYYY, in 9800 YYYY/MM/DD so I can do a substring


var t=(datefin2-datefin23)/86400000/365;


when I do

var datefin2=new Date(dat2) 

it says invalid date...


Ho do I convert the url.getURLParameter"date3");


Anyways thanks for the help :-)


Posts: 669
Registered: ‎02-19-2011
My Device: BlackBerry PlayBook 32GB
My Carrier: Sprint

Re: working with html5 date input

I suppose the key in unifying these dates would be to have a little table with locales and their corresponding date format. You can then check what locale the user's phone is set to and then convert your dates to one uniform format accordingly (and convert back of course when you display them somewhere).


Staff UI Prototyper (read: full-time hacker)

My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App

Posts: 16
Registered: ‎05-17-2011
My Device: 9700
My Carrier: Bmobile

Re: working with html5 date input

Any chance you could share the code you are using to generate the dat/datetime spinner control?


I haven't been able to get it to appear in my webworks application



Posts: 37
Registered: ‎12-24-2010
My Device: Tour
My Carrier: Verizon

Re: working with html5 date input

The html5 date input uses the ISO date format (yyyy-MM-DD). If you use the following it should work on all devices:



var d = new Date(document.getElementById("date2").value.replace(/-/gi, "/"));