JQuery- using a variable outside of the scope of the function
<p>I have the following JQuery function:</p>

<pre><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></pre>

<p>My questions is:</p>

<p>In "<strong>var t2</strong>" instead of a fixed value how can I use "<strong>var currentDate</strong>" ?</p>

<p>More precisely,
I want to use the <strong>value</strong> from <code>onSelect: function(value)</code>  in t2. </p>

<p>That means whenever a new value is assigned to <strong>currentDate</strong>, i want it to be passed in <strong>t2.</strong></p>
