I have a script what insert a date from the value of a input:
PHP:
<input type="text" id="datepicker" name="expire" placeholder="dd-mm-yyyy" value="<?php echo (DateTime::createFromFormat('d-m-Y', date("d-m-Y"))->modify('+1 day')->format('d-m-Y')); ?>" />
You can also edit the date by a date picker!
But when I insert it to the database with this query:
$mysql->query("INSERT INTO code(code, file_match, file_size, expire, ip, can_used)
VALUES ('".$mysql->real_escape_string($_POST['code'])."',
'".$mysql->real_escape_string($_POST['bestand'])."',
'".filesize('./Hier_je_files/'.$mysql->real_escape_string($_POST['bestand']))."',
'".time($mysql->real_escape_string($_POST['expire']))."',
'".$mysql->real_escape_string($_POST['ip_whitelist'])."',
'".$mysql->real_escape_string($_POST['used'])."')"
And then echo it with this:
<?php echo date('d-m-Y H:i:s', $info['expire']); ?>
Output is always the date of to day:

Database:

I dont know why, and how to fix it.
time()doesn't take any arguments and always returns the current time. You're looking for something likestrtotime($input)or preferablyDateTime::createFromFormat($format, $input)->getTimestamp().../index.phpin the$_POST['bestand']field.$info['expire']is. My guess is that it'snull.