I want to convert datetime format for my radtime picker. I am getting 2012-8-2-13-00-00
as my output when I pick date from my radtime picker. When I try to convert in to date it is saying invalid date.
The JavaScript:
function SourqtyValidation()
{
var specifiedtime = document.getElementById('<%=txtSpecifiedArrvialTime.ClientID %>').value;
alert(specifiedtime);
var a = new Date(specifiedtime);
var actuvalarrivaltime = document.getElementById('<%=txtActualArrivalTime.ClientID %>').value;
alert(actuvalarrivaltime);
var b = new Date(actuvalarrivaltime);
b.format("dd/MM/yyyy hh:mm:ss");
alert(b);
var difference =Math.round((a - b) / 1000);
alert(difference);
}
The aspx:
//txtSpecifiedArrvialTime = predifened as 2012/08/02 09:35:55;
<telerik:RadTimePicker ID="txtActualArrivalTime" runat="server" EmptyMessage="Actual Arrival Time"> </telerik:RadTimePicker>
So how can I get difference between two times in minutes?
to get the time difference,date should be in same format,
"2012-8-2-13-00-00" is not the correct format, convert it into format of "2012/08/02 13:00:00"
than you can get the differencein in second by dividing it to 1000.
you can use this to convert your string to datetime
var dt = '2012-8-2-13-00-00'.split(/\-|\s/);
dat = new Date(dt.slice(0,3).reverse().join('/')+' '+dt[3]+':'+dt[4]+':'+dt[5]);