I’m trying to deconstructing current timestamp and then use mktime(…) to reconstruct it using values passed through $_GET
Here is my code so far.
$date =time ();
if(!empty($_GET['month'])){
if(!empty($_GET['year'])){
$f = getdate($date);
$date = mktime($f["hours"], $f["minutes"], $f["seconds"], $_GET['month'],
$f["days"], $_GET['year']);
}
}
$date is used later on and it still equals current time().
Outputs:
http://codepad.org/NWLt7ER6
EDIT
Also, as far as checking the input, I would set it up to only accept numeric values, and validate those.
You also might want to put that in a function and call it, use it in an object scope, or use more specific global variable names than
$date.EDIT
And as profitphp points out, using a day for another month when that day doesn’t exists pushes into the next month (September and February do not have 31 days):
Outputs:
http://codepad.org/RFXTze5z