JQuery DatePicker & PHP

Hi All,

I’m probably missing something really silly but how to I get the date picked using JQuery’s Datepicker (UI/API/1.7.1/Datepicker - jQuery JavaScript Library) into a variable I can use in a PHP script?

I can’t seem to figure out what to pull out of $_REGISTERS OR $_POST.

Thanks in advance.


Javascript date pickers (and other kinds of client side pickers) work by assigning the output to a field in the form that you specify. This would be a field that would be normally typed in by hand. If you do not want users to be able to change that form field by typing, then make it readonly. So the user sees that the datepicker has “filled in” the field for them when a date is clicked on.

You then process the form as normal. Nothing PHP specific either, works with any other server-side technology.

Hi kev,
here’s an example to assign the output to a field, as mentioned in the previous post,

<!DOCTYPE html>
  <link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
  <script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
  <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
  <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.datepicker.js"></script>
  <script type="text/javascript">
 onSelect: function(dateText, inst) { alert(dateText);document.getElementById('thedate').value=dateText; }
<body style="font-size:62.5%;">
<div type="text" id="datepicker"></div>
<form method=post>
<input type='text' id='thedate' name='thedate' />

the date chosen is in $_POST’thedate’]


Cool, thanks for your help. :slight_smile:


Glad to help :slight_smile:

Instead of JQuery you can also use other third party datapicker code.

Cheap Custom Boxes, Software Boxes, Corrugated Boxes, wholesale boxes, Display Boxes, Shipping Boxes.

hey there,
I did the same thing, expected that $_POST’thedate’] will return value in text box, instead it returned NULL.:\


Are you aware you’re reopening a 6 year old thread?