I had a application working fine, then the server people upgraded to php5, of course now certain things dont work (well didn't) I have managed to fix all the issues apart from this one

$tstamp = mktime($hour,$minute,$second,$month,$day,$year);

switch ($format):
case "1":
  $sDate = date("l jS F Y",$tstamp);
  break;
case "2":
  $sDate = date("d/m/y",$tstamp);
  break;
case "3":
  $sDate = date("d/m",$tstamp);
  break;
case "4":
  $sDate = date("j M Y",$tstamp);
  break;
case "5":
  $sDate = date("D jS M",$tstamp);
  break;
default:
  $sDate = date("d/m/y H:i",$tstamp);
  break;
endswitch;

return $sDate;}

This is genorating a error message saying

Fatal error: Cannot redeclare date_format()

Can someone please show me what needs changing?

    Let me guess: this code snippet is within the implementation of a function named date_format? If so, just rename the function so that the name does not conflict with PHP's own date_format() function.

      13 days later

      Also note that when dealing with date(), it is wise to set a default time zone, otherwise, behind the scenes, there will be a Strict Standards issue.

      For good measure, include the following php code (preferably at the top of the page):

      error_reporting(E_ALL | E_STRICT);
      

      Then choose the appropriate timezone by including something along the lines of:

      date_default_timezone_set('America/Montreal');
      

      Obviously, change America/Montreal to your desired location. A list of timezones can be found here.

        Write a Reply...