JQuery- using a variable outside of the scope of the function

Webworma

New Member
I have the following JQuery function:\[code\]jQuery(function() { jQuery("#datepicker").datepicker({ onSelect: function(value) { alert('The chosen date is ' + value); currentDate= Math.round(Date.parse(value)/ 1000); } }); // TODO // on select of a time value trigger the action jQuery("#timepicker").timepicker({ 'timeFormat': 'H:i'}) val = jQuery("#timepicker").val(); currentTime= Math.round(Date.parse(val)/ 1000); var t1 = new Date(currentTime * 1000); var t2 = new Date(1364598000 * 1000); var t3 = new Date(t2.getFullYear(), t2.getMonth(), t2.getDate(), t1.getHours(), t1.getMinutes(), t1.getSeconds(), t1.getMilliseconds()); console.log(t3); var timestamp = t3.getTime() / 1000; });\[/code\]My questions is:In "var t2" instead of a fixed value how can I use "var currentDate" ?More precisely,I want to use the value from \[code\]onSelect: function(value)\[/code\] in t2. That means whenever a new value is assigned to currentDate, i want it to be passed in t2.
 
Back
Top