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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you, I renamed it now my script pretty much prints everything until it gets to that section. Do I have the call correct?
I can see no problem with the call. what is the argument string and what did you rename it to?
I changed it to ModDate.
@dcary You need to find your error logs, or read up on how to make PHP display errors while you're developing. See stackoverflow.com/questions/12769982/… Then if you don't understand the error message, see if the other sections on that page help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.