bravo14 Posted August 12, 2011 Share Posted August 12, 2011 Hi I am trying to merge to fields to make a date and time. The date field is calculated to be 4 days from today and the time is selected from a select menu using the following code <select name="end_time"> <option value="12:00:00">12:00 Noon</option> <option value="17:00:00">5:00pm</option> </select> Using the following php script $end_time=strtotime("H:i",$_POST['end_time']); //Line 35 $date=date("Y-m-d"); $end_date=strtotime($date ."+4 days" ); $end_date_time=$end_date.$end_time; $add_vehicle_sql=mysql_query("INSERT INTO `tbl_auction_lot`(`cust_id`,`reserve`,`make`,`model`,`spec`,`fuel`,`doors`,`mot_date`,`fns`,`fos`,`rns`,`ros`,`condition`,`reg_no`,`service_history`,`sale_type`,`status`,`keepers`,`gearbox`,`emissions`,`colour`,`date_first_reg`,`date_manufacture`,`bhp`,`engine_size`,`end_date`,`current_price`) VALUES ('$seller_id','$reserve','$make','$model','$body_style','$fuel_type','$no_of_doors','$mot','$fns','$fos','$rns','$ros','$vehicle_condition','$vrm','$service_history','auction','$status','$prev_keepers','$gearbox','$emissions','$colour',$date_reg','$date_man','$bhp','$engine_size', '$end_date_time','$reserve')") or die(mysql_error()); I am getting the following error message Notice: A non well formed numeric value encountered in /home/sites/trade-bidz.co.uk/public_html/add-vehicle.php on line 35 What have I done wrong? Link to comment https://forums.phpfreaks.com/topic/244585-trying-to-merge-date-and-time-fields/ Share on other sites More sharing options...
JasonLewis Posted August 12, 2011 Share Posted August 12, 2011 I think you're getting confused with strtotime() on line 35. You might want to use date() there instead as that would be better suited. Link to comment https://forums.phpfreaks.com/topic/244585-trying-to-merge-date-and-time-fields/#findComment-1256294 Share on other sites More sharing options...
bravo14 Posted August 12, 2011 Author Share Posted August 12, 2011 Hi I have changed the code on line 35 to $end_time=date("H:i",$_POST['end_time']); I am still getting the same error message Link to comment https://forums.phpfreaks.com/topic/244585-trying-to-merge-date-and-time-fields/#findComment-1256448 Share on other sites More sharing options...
JasonLewis Posted August 12, 2011 Share Posted August 12, 2011 Sorry, you should probably use strtotime on the $_POST variable. $end_time = date("H:i", strtotime($_POST['end_time'])); The reason being is you want the unix timestamp of the time you select in the dropdown. Link to comment https://forums.phpfreaks.com/topic/244585-trying-to-merge-date-and-time-fields/#findComment-1256463 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.