Page 1 of 1

php5 N date?

Posted: Sun Nov 06, 2005 12:03 am
by blacksnday
One thing I noticed on my local install compared to my web server install
is that the displaying of date doesnt work correctly
on php5 compared to php4.
Was there a change that caused this?

My current DB is
Date timestamp(14)
on php4 it displays correct as
11-06-2005
but on php5(local install) it displays as
-1-1--2005

The current convert code being used on both installs is:

Code: Select all

$date2 = $row['date']; 
      $year = substr($date2, 0, 4); 
      $month = substr($date2, 4, 2); 
      $day = substr($date2, 6, 2); 
      $date = "$month-$day-$year";

Posted: Sun Nov 06, 2005 12:26 am
by feyd
it has more to do with how your selection is being returned.. In your php4, the timestamp field is being returned as '20051106...' whereas php5 is getting '2005-11-06...'

Use DATE_FORMAT() to create the date you want to display..

Posted: Sun Nov 06, 2005 12:59 am
by blacksnday
thanks! that worked