-2

I think the question says it all. I am not sure how to get the currentdate + 2 days. here was my attempt

//insert invoice table
                $currentdate = getdate();
                $duedate = getdate() + 2000;
                $makeinvoice = mysql_query("INSERT INTO invoices (userid, hostid, price, ispaid, detecreated, duedate) VALUES ('$userid', '$prodid', '$initprice', '0', '$currentdate','$duedate' )",$conn);
CudoX
  • 985
  • 2
  • 19
  • 31
  • i use it on mysql_query to insert the current date and time. – CudoX Apr 03 '14 at 01:15
  • i think it has to be like that which will be inserted to the mysql datetime data – CudoX Apr 03 '14 at 01:16
  • Well, there aren't 2 thousand of anything meaningful in two days, and [`getdate()`](http://php.net/getdate) returns an array, so this isn't much of an attempt. Have a look at [the many date functions in PHP](http://php.net/manual/en/ref.datetime.php) and see if you can spot one more suited to the job. – IMSoP Apr 03 '14 at 01:17

2 Answers2

3

am assuming you want to get a unix timestamp. just use strtotime('+ 2 days')

EDIT

//insert invoice table
$currentdate = time();
$duedate = strtotime('+2 days');

$makeinvoice = mysql_query("INSERT INTO invoices (userid, hostid, price, ispaid, detecreated, duedate) VALUES ('$userid', '$prodid', '$initprice', '0', '$currentdate','$duedate' )",$conn);

P.S, you should use the mysqli extention as mysql is old and would be discontinued soon. Or better still, use pdo

jcobhams
  • 796
  • 2
  • 12
  • 29
0

This should return a timestamp 2 days ahead

$due_date = strtotime('+ 2 days');
  • [No it won't.](http://3v4l.org/n8jlZ) The reason being that `strtotime('+ 2 days')` *already* assumes you mean two days *from now*, not from the beginning of time, so adding it onto the current time will give you a very large timestamp, a lot more than two days in the future! – IMSoP Apr 03 '14 at 01:27