I have a jQuery date that I am passiving via ajax to a php script then using the date in an sql insert into mysql database
<p>I have a javascript date that I am passing via ajax to a php script then using the date in an sql insert into mysql database. I can't figure out how to format the date so the SQL call accepts it. Can anyone help with this?</p>

<p>In the AJAX call I've tried passing the date object as is, converting to JSON, to UTC.</p>

<p>The error I get is:</p>

<blockquote>
  <p>Incorrect date value: 'Thu, 01 May 1902 03:01:00 GMT' for column 'uspr_dob' </p>
</blockquote>

<p>This all works if I remove the date line from the SQL code. ie I update the other fields but not the date. So everything else is working except the date passing.</p>

<p>jQuery date formation:</p>

<pre><code>    var dob = new Date(year, month, day, hours, minutes, 0, 0);
</code></pre>

<p>jQuery AJAX call:</p>

<pre><code>    var save_result = jQuery.ajax({
                url: lb_path + "update_user.php",
                data: { 'lb_user_id'    : this.id,
                        'lb_dob'        : this.dob.toUTCString(), //toJSON
                        ... },
                type: 'POST',
                datatype: 'json',
                success: function(data, status) {
                      ...
                }, // End success
                error: function (xhr, ajaxOptions, thrownError) {
                    ...
                  }
       }); // End load the supplement list
</code></pre>

<p>PHP code is:</p>

<pre><code>        $sql = "UPDATE userpref
        SET uspr_person_group       = \"".$lb_gender."\",
            uspr_diet_type          = (SELECT diet_id FROM diet WHERE diet_name = \"".$lb_diet."\"),
            uspr_exercise_profile   = (SELECT exprof_id FROM exercise_profile WHERE exprof_name = \"".$lb_exercise."\"),
            uspr_dob                = \"".$lb_dob."\"
        WHERE uspr_user_id = ".$lb_user_id;
</code></pre>