0

I have a php script where I need to update the date format from CYYMMDD to MM/DD/YYYY, I wrote a function to do this for me, however when I go to print it, the result says 'Array'.

//Modify Date Format from CYYMMDD to MM/DD/YY

function getDate(string $iDATE){

    $iDay = substr($iDATE,5,2);
    $iMonth = substr($iDATE,3,2);
    $iYear = substr($iDATE,1,2);
    

    $iDATE = $iMonth . "/" . $iDay . "/" . $iYear;
    RETURN $iDATE;
}

Here is the line I'm trying to call the function from:

print "<td align='left' class='Col2'><font face='Calibri' size='3'>".getDate($iDATE)."</td>";

Output : Array

Any thoughts?

dcary
  • 69
  • 6

1 Answers1

2

getdate is a predefined PHP function that returns an array https://www.php.net/manual/en/function.getdate.php

You should rename your function or encapsulate it in a namespace.

CFulford
  • 73
  • 6
  • Thank you, I renamed it now my script pretty much prints everything until it gets to that section. Do I have the call correct? – dcary Aug 17 '22 at 21:36
  • I can see no problem with the call. what is the argument string and what did you rename it to? – CFulford Aug 17 '22 at 21:40
  • I changed it to ModDate. – dcary Aug 17 '22 at 21:50
  • @dcary You need to find your error logs, or read up on how to make PHP display errors while you're developing. See https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/12772851#12772851 Then if you don't understand the error message, see if the other sections on that page help. – IMSoP Aug 17 '22 at 22:14