[英]php print current day plus to days
我认为这个问题说明了一切。 我不确定如何获得当前日期 + 2 天。 这是我的尝试
//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);
我假设你想得到一个 unix 时间戳。 只需使用strtotime('+ 2 days')
编辑
//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);
PS,你应该使用mysqli
扩展,因为mysql
很旧,很快就会停产。 或者更好的是,使用pdo
这应该提前 2 天返回时间戳
$due_date = strtotime('+ 2 days');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.