php5 N 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
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

php5 N date?

Post 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";
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

Post by blacksnday »

thanks! that worked
Post Reply