title: jQuery: How to pass value from one function to another?
body: <p>UPDATE: </p>
  
  <p>Here is a simplified version of what I'm trying to figure out (see the question in the comment): </p>
  
  <pre><code>        $("document").ready(function() {
          $("#startDate").datepicker({
  
              onSelect: function(dateText, inst) { 
                  var dateAsObject = $(this).datepicker( 'getDate' );
                  var timestamp = dateAsObject.getTime(); // the timestamp of the date picked by user
              }
          });
  
          // how do I get the value of timestamp to show up here?
          // It also needs to update every time onSelect changes the value.
          alert(timestamp);
  
      });
  </code></pre>
  
  <hr>