This PHP function creates dropdown select lists for time and date that you can
change, outputs a 14 char MySQL timestamp in a text field Enjoy this - I'm sure it could be more elegant, but I couldn't find something like this anywhere else. Pull your hair out on more important programming problems! If you like it, or improve upon it, drop me a line. call the function like this: stamper($previous_value); ?> function stamper($previous_value) { // your constants $form_name = "form1"; $store_stamp_field = "datestamp"; // looks for previous 14 char stamp or defaults to now if (!$previous_value) { $my_stamp = date("YmdHis"); } else { $my_stamp = $previous_value; } // parses the timestamp & digests it into useful variables $year=substr($my_stamp,0,4); $month=substr($my_stamp,4,2); $day=substr($my_stamp,6,2); $hour=substr($my_stamp,8,2); $minute=substr($my_stamp,10,2); $second=substr($my_stamp,12,2); // here you can set your ("starting value", "range") for each $year_range = array("2000","11"); $month_range = array("01","12"); $day_range = array("01","31"); $hour_range = array("00","24"); $minute_range = array("00","60"); $second_range = array("00","60"); $names = array("month","day","year","hour","minute","second"); $names_for_stamp = array("year","month","day","hour","minute","second"); // this drops in some javascript to do the onChange event handler for each select list echo "\n"; // this creates the selects and add the JS event handler for ($i=0;$iecho "\n"; } //this creates the initial timestamp $the_stamp = $year . $month . $day . $hour . $minute . $second; //this holds the dynamic timestamp value, make it hidden once you get the hang of how it all works echo "\n"; } ?>