skip to Main Content

I have Created the Program where I am Fetching the Content from a text file from a cpanel server,
In my Table Fields It shows the Date Format in Server format i.e (YYYY/MM/DD) I want it to Display as
(DD/MM/YYYY).
This is My Code

<?php
    $data = file_get_contents("file-path.txt");
    $arr = explode(";", $data);
    echo "<thead>";
        echo "<tr style="border: 1px solid black;">";
                echo "<th style="border: 1px solid black;">Doctor Name</th>";
                echo "<th style="border: 1px solid black;">Leave From (YYYY/MM/DD)</th>";
                echo "<th style="border: 1px solid black;">Leave To (YYYY/MM/DD)</th>";
                echo '<th style="border: 1px solid black;">Remarks</th>';
                echo "</tr>";
        echo "</thead>";
        echo "<tbody>";
            for($value = 0; $value < count($arr)-1; $value=$value+4) {
                echo "<tr style="border: 1px solid black;">";
                echo "<td style="border: 1px solid black;">".$arr[$value]."</td>";
                echo "<td style="border: 1px solid black;">".$arr[$value+1]."</td>";
                echo "<td style="border: 1px solid black;">".$arr[$value+2]."</td>";
                echo '<td style="border: 1px solid black;">'.$arr[$value+3].'</td>';
                echo "</tr>";
            }
        echo "</tbody>";
        echo "</table>";
?>

2

Answers


  1. You should use date_format() function bro
    date_format($arr[$value+2],"d/m/Y");

    Login or Signup to reply.
  2. date('d/m/Y', strtotime($arr[$value+2]));
    

    Have a try, you can do it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search