php - Adding days to a certain date -
i got date want add together amount of days. seek alter this:
echo date('d-m-y', strtotime($row_rsacessorios['data_pedido']. ' + 10 days')); into this:
$numdays = $row_rsacessorios['dias']; echo date('d-m-y', strtotime($row_rsacessorios['data_pedido']. ' + ' . $numdays . ' days')); my result same time "1-1-1970"
if assume $numdays = 12 gives me right date. mysql date format yyyy-mm-dd
small test.
$num = '10'; var_dump(date('d-m-y', strtotime("+ $num days"))); $testdate = date('d-m-y'); var_dump(date('d-m-y', strtotime($testdate. " + $num days"))); after comment update,
$num = 12; $testdate = '2013-04-10'; var_dump(date('d-m-y', strtotime($testdate. " + $num days"))); you gave information, works.
please check $row_rsacessorios['data_pedido'] , $days variable.
example:
http://codepad.viper-7.com/6oytfb
http://codepad.viper-7.com/kgb7bx (after)
php mysql date add
No comments:
Post a Comment