Answered by:
DatePicker & TimePicker control in WinJS.UI.DatePicker & WinJS.UI.TimePicker

Question
-
Hi all,
I am creating a metro application using HTML5 & JavaScript. I am trying to use DatePicker & TimePicker control in my application.
When I retrieve the DatePicker value, It shows me the UTC part of date too like this:
Sat Jan 25 12:00:00 UTC +0530 2014 ( I want only Sat Jan 25 2014) not 12:00:00 UTC +0530
Similarly with TimePicker the value show as:-
FRI Jul 15 16:38:00 UTC +0530 2011 ( time part is correct) but I do not want FRI Jul 15 UTC + 0530 2011.
How can I do It.
Please help me with some guidelines.
Thanks,
Vishwajeet.
Saturday, January 25, 2014 11:34 AM
Answers
-
Hi,
Put the value in the Date object: http://msdn.microsoft.com/en-us/library/windows/apps/cd9w2te4.aspx
and extract the values you want.
You can code like below:
function dateDemo() { var s=""; this.datePicker = document.getElementById("datePicker"); this.datePicker.addEventListener("change", function () { s+= datePicker.current.getDate(); s+ = datePicker.current.getMonth() + 1; s+ = datePicker.current.getFullYear(); }); }
Refer to the link:
http://msdn.microsoft.com/en-us/library/windows/apps/br211674.aspx
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- Marked as answer by Vishwajeet (MCA,MCP,MCTS,MCITP) Monday, January 27, 2014 7:56 AM
Monday, January 27, 2014 6:18 AM
All replies
-
Hi,
Put the value in the Date object: http://msdn.microsoft.com/en-us/library/windows/apps/cd9w2te4.aspx
and extract the values you want.
You can code like below:
function dateDemo() { var s=""; this.datePicker = document.getElementById("datePicker"); this.datePicker.addEventListener("change", function () { s+= datePicker.current.getDate(); s+ = datePicker.current.getMonth() + 1; s+ = datePicker.current.getFullYear(); }); }
Refer to the link:
http://msdn.microsoft.com/en-us/library/windows/apps/br211674.aspx
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.- Marked as answer by Vishwajeet (MCA,MCP,MCTS,MCITP) Monday, January 27, 2014 7:56 AM
Monday, January 27, 2014 6:18 AM -
Thanks a lot. It helped me and gave me helpful information.
I used the following and it started showing the result as expected.
convertedDate = selectedDate; ( the value of selectedDate variable is the value of the datePicker control)
convertedDate = convertedDate.toLocaleDateString();toLocalDateString() method of the Date class gives the result as expected.
Is this the right way to do it.
Thanks again :)
Monday, January 27, 2014 7:56 AM