Dup Ver Goto

datetime

23 lines, 69 words, 672 chars Sunday 2023-12-03 17:47:46

Now that strftime() is deprecated:

<?php
$formatter = new IntlDateFormatter('en_GB', IntlDateFormatter::LONG, IntlDateFormatter::NONE);
echo $formatter->format(time()); # only date
$formatter = new IntlDateFormatter('en_GB', IntlDateFormatter::LONG, IntlDateFormatter::LONG);
echo $formatter->format(time()); # date time

$timestamp = 424343;
$d = new DateTime('@'.$timestamp);
$dt = $d->format('l Y-m-d H:i:s T');
echo "<tr><td><a href='/$path'>$p</a></td><td><span class='mtime'>".$dt."</span></td></tr>\n";

Mtime example

<?php
$mtime = filemtime("bobbins.txt");
$d = new DateTime('@'.$mtime);
$dt = $d->format('l Y-m-d H:i:s T');
echo $dt;
?>