Jump to content

Add 4 days to today


bravo14
 Share

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
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
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
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.