Get the value from a datepicker field

Get the value from a datepicker field

Hi i recently learning jquery but i've to the point where i don't know how to do something that i know how to do like old school javascript.
So i'm using a datepicker field and i'm trying to send the value to a db through a button field but it is the format how sends the value.
I'm using an alert type to see which value is sending and it is like this:
  1. Thu Dec 02 2010 00:00:00 GMT-0600

So how could i give a format to store the value in the correct way for my db like : 12-02-2010?

This is my code which works fine
  1. <script type="text/javascript" src="js/previos/jquery-1.4.1.js"></script>
    <script type="text/javascript" src="js/jquery-ui/jquery-ui-1.7.2/ui/ui.core.js"></script>
    <script type="text/javascript" src="js/jquery-ui/jquery-ui-1.7.2/ui/ui.datepicker.js"></script>
    <script type="text/javascript" src="js/jquery-ui/jquery-ui-1.7.2/ui/i18n/ui.datepicker-es.js"></script>
    <script type="text/javascript">
        $(function() {
            $("#datepicker").datepicker();
            $("#format").change(function() { $('#datepicker').datepicker('option', {dateFormat: $(this).val()}); });
        });
        
        $(function(){

    $("#agregar").bind("click", function() {
      alert($("#datepicker").datepicker("getDate"));
    });});
        </script>














  2. <body>

    <div class="demo">

    <p>Date: <input type="text" id="datepicker" size="30"/></p>

    <p>Format options:<br />
        <select id="format">
            <option value="mm/dd/yy">Default - mm/dd/yy</option>
            <option value="yy-mm-dd">ISO 8601 - yy-mm-dd</option>
            <option value="d M, y">Short - d M, yy</option>
            <option value="d MM, y">Medium - d MM, yy</option>
            <option value="DD, d MM, yy">Full - DD, d MM, yy</option>
            <option value="'day' d 'of' MM 'in the year' yy">With text - 'day' d 'of' MM 'in the year' yy</option>
        </select>
    </p>

    </div><!-- End demo -->

    <div class="demo-description">

    <p>Display date feedback in a variety of ways.  Choose a date format from the dropdown, then click on the input and select a date to see it in that format.</p>

    </div><!-- End demo-description -->
    <button id="agregar" name="agregar">Agregar</button>
    </body>
























And i have another question on how to develop with jquery.
Do i always have to start with a ready() function or just like the pesudo function $(function() {}?

I hope someone could help me.
Thanks