Datepicker how to and best practice

Hello,

subject: datepicker.

I have a datepicker which to select an expire date and it works, example output from the user datepicker: Array ( [date] => 30-April-2014 [hidden1] => 1398830400).

how do I go about calculating the amount of date/time remaining as it gets closer to the end date?
looking to do somehthing like ebay, display the amount of time and date left before the bid closes.



<?php
if(isset($_POST['btn_send'])) {print_r($_POST);}
?>
<html>
	<head>
		<script >
                      $(document).ready(function()
                      {	      $("#date").datepicker(
	                       {	showButtonPanel: true,
		                        minDate: '0M',
		                        maxDate: '+90D',	
		                        dateFormat: "d-MM-yy",	
		                       onSelect : function(dateText, inst)
		                       {	var epoch = $.datepicker.formatDate('@', $(this).datepicker('getDate')) / 1000;
			                       $("#hidden1").val(epoch);
		                       }
                                });	
                    });
            </script>
		
	</head>
	<body>
		<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='POST' accept-charset='UTF-8'>
			<label id='fieldTitle'> Select end date: </label><br>
			<input type="text"   name="date"    id="date"    value="<?php echo empty($_POST['date'])   ? NULL : $_SESSION['date1'];   ?>" />	
				<input type="hidden" name="hidden1" id="hidden1" value="<?php echo empty($_POST['hidden1'])? NULL : $_SESSION['hidden1']; ?>" />
				<input type="submit" name="btn_send" >
		</form>
	</body>
</html>

any help you can give would be greatly appreciated.

This should do what you need:
http://www.php.net/manual/en/datetime.diff.php