Today's date showing up instead of _POST selected date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
avstudio1
Forum Newbie
Posts: 13
Joined: Mon Nov 07, 2005 5:20 pm

Today's date showing up instead of _POST selected date

Post by avstudio1 »

Hi,

Can someone help with this. I have a date which is being posted by another page. My dates look ok when they are together, but when I try to break them up into components, then it reverts back to today's current date.


First take a look at the posting page which creates a drop down list to select fom the last several days:

Code: Select all

<form action="test.php" method="POST">
<select name="PickDate">
<?
for ($i = 0; $i <= 15; $i++) {
     $today = mktime (0,0,0,date("m") ,date("d")-$i ,date("Y"));
     $option=date("D M j, Y",$today);
     $value=date("m:d:Y",$today);
     echo "<option value=\"$value\" $selected>$option</option>\n";
}
?>
<input type=submit>

The result looks like the following: (Say I selected Dec. 31, 2005 from the list and today is Jan. 3, 2006)

Code: Select all

$Postvalue = $_POST['PickDate'];
echo $Postvalue;
echo "</br>";

$PickDay = date ("d", strtotime($Postvalue));
$PickMonth = date("m", strtotime($_POST['PickDate']));
$PickYear = date("Y", strtotime($_POST['PickDate']));

echo $PickDay;
echo "</br>";
echo $PickMonth;
echo "</br>";
echo $PickYear;
echo "</br>";

This outputs the following:

12:31:2005
03
01
2006


Any ideas?

Thanks,
Justin
avstudio1
Forum Newbie
Posts: 13
Joined: Mon Nov 07, 2005 5:20 pm

Post by avstudio1 »

once again i think i solved my own question by removing the formatting from the value portion of the select variable

Code: Select all

$value=$today;
and then simply ...


Code: Select all

$PickDay = date("d", $_POST['PickDate']);
$PickMonth = date("m", $_POST['PickDate']);
$PickYear = date("Y", $_POST['PickDate']);
Post Reply