Jump to content

Add 4 days to today


bravo14

Recommended Posts

Hi I am trying to add a field to a database that is 4 days from the date the record is added, but it is not adding a value

 

$end_date=strtotime("+ 4 days");

$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`)
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')") or die(mysql_error());

 

What am I doing wrong and what is there a better way to achieve the desired result.

Link to comment
https://forums.phpfreaks.com/topic/231730-add-4-days-to-today/
Share on other sites

The strtotime() function is notoriously strict on the input you can give it.  I'm not particularly well versed in its acceptable syntax, but I would guess that you cannot have any whitespace between the plus sign and the integer when marking it 4 days from now.

Link to comment
https://forums.phpfreaks.com/topic/231730-add-4-days-to-today/#findComment-1192365
Share on other sites

Hi I am trying to add a field to a database that is 4 days from the date the record is added, but it is not adding a value

 

What am I doing wrong and what is there a better way to achieve the desired result.

 

What is the column type of your end_date column? Remember that you're giving it a Unix timestamp (an integer, the number of seconds since 1 Jan 1970) and that may well be different from what MySQL expects.

 

The strtotime() function is notoriously strict on the input you can give it.  I'm not particularly well versed in its acceptable syntax, but I would guess that you cannot have any whitespace between the plus sign and the integer when marking it 4 days from now.

 

The date/time formats are well documented (though can be a lot to digest, and lack version changes/information).

 

Link to comment
https://forums.phpfreaks.com/topic/231730-add-4-days-to-today/#findComment-1192589
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.