PDA

View Full Version : mktime() and date() troubles


madmatter23
09-23-2007, 03:39 AM
Alright. I'm attempting to do something very simple, but I can't seem to figure out where the problem lies.

My users submit the date in format mm/dd/yyy via post, and I then want to display in a particular format using the date() and mktime() functions.


//format class dates
$classdate[0] = $_POST['classyear'];
$classdate[1] = $_POST['classmonth'];
$classdate[2] = $_POST['classday'];
$classdate = implode("-",$classdate);
$classdateDisplay= date('F d, Y', mktime(0,0,0,$classdate[1],$classdate[2],$classdate[0]));

echo "debug: \$classdate = $classdate<br />";
echo "debug: \$classdateDisplay = $classdateDisplay<br />";


When I enter the values 2008/01/01 in the form, $classdate then correctly is displayed as 2008-01-01.

But when I echo $classdateDisplay, it displays "December 3, 2001."

I'm following the formatting as described http://us.php.net/mktime (here), which is:


int mktime ( [int $hour [, int $minute [, int $second [, int $month [, int $day [, int $year [, int $is_dst]]]]]]] )


What am I missing here?

Thanks in advance.

Inigoesdr
09-23-2007, 05:10 AM
What am I missing here?

$classdate = implode("-",$classdate);

madmatter23
09-23-2007, 05:32 AM
omg I'm an idiot. It's really funny how all you have to do is show me a line of my own code and somehow that makes it click.
Sometimes I guess I just need to take a break and try again later to recognize my own errors.

You save me yet again Inigoesdr