PDA

View Full Version : vbdate() returning wrong date


kyrnel
12-22-2003, 10:39 PM
I wrote a simple PHP script to display upcoming events on the ForumHome page but when I try to format the date, it always shows Dec 31, 1969.

$up_eventdate = vbdate("M-d",$event[eventdate]);

$event[eventdate] returns the appropriate value in the format 'Y-m-d'.
I just want to change that to 'M-d' format.

Is this not working because the array is returning a string value for the date?
I thought vbdate() would convert a string to a date if it was a valid date format.

Anyone have any ideas here?

kyrnel
12-23-2003, 01:04 AM
I figured it out.

My suspicion was correct, since dates are typically stored as integer values the vbdate() function (and even the date() function it uses) cannot accept string values as the timestamp argument.
I had to use the strtotime() function to first convert the string date to an actual date value before using the date() function to modify its format.

$eventdate2 = strtotime($event[eventdate]);
$up_eventdate = date("M-d",$eventdate2);

That did it. PHP is fun. :)

Now if I could only figure out what this stuff means:
/"".=.""/

eval statements still confuse me....