Friday 2 November 2012

PHP Date()

PHP Date() - Format the Date

The required format parameter in the date() function specifies how to format the date/time.
Here are some characters that can be used:
  • d - Represents the day of the month (01 to 31)
  • m - Represents a month (01 to 12)
  • Y - Represents a year (in four digits)
 Other characters, like"/", ".", or "-" can also be inserted between the letters to add additional formatting:
<?PHP
         echo date("Y/m/d") . "<br/>";
        echo date("Y.m.d") . "<br/>";
        echo date("Y-m-d");
?>
 The output of the code above could be like this:
2012/11/01
2012.11.01
2012-11-01

Monday 6 August 2012

PHP CSV File Reading


CSV File Reading In PHP

<?php
$fp = fopen('example.csv','r') or die("can't open file");
print "<table>\n";
while($csv_line = fgetcsv($fp,1024)) {
    print '<tr>';
    for ($i = 0, $j = count($csv_line); $i < $j; $i++) {
        print '<td>'.$csv_line[$i].'</td>';
    }
    print "</tr>\n";
}
print '</table>\n';
fclose($fp) or die("can't close file");
?>