Global date formatting function

This commit is contained in:
Fredrik Lindberg Strupe 2016-08-26 23:14:46 +02:00
parent a4787387dd
commit f39389ead4
4 changed files with 10 additions and 3 deletions

View File

@ -20,6 +20,10 @@ class Agenda {
$this->activities = $activities;
}
public static function getFormattedDate($date) {
return trim(strftime('%A %e. %b %H.%M', $date->getTimeStamp()));
}
public function getEventsBetween(DateTimeImmutable $from, DateTimeImmutable $to) {
$results = [];
for($i = 0; $i < sizeof($this->activities); $i++) {

View File

@ -4,6 +4,7 @@ date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
require __DIR__ . '/../../src/_autoload.php';
require __DIR__ . '/../../sql_config.php';
use \pvv\side\Agenda;
?>
<html lang="no">
<title>Sosialverkstedet</title>
@ -35,7 +36,7 @@ $nextEvent = $activity->getNextEventFrom(new DateTimeImmutable);
<ul class="subtext">
<li>Tid:
<strong>
<?= $nextEvent->getStart()->format('Y-m-d H:i');?>
<?= Agenda::getFormattedDate($nextEvent->getStart());?>
</strong>
<li>Sted:
<strong>

View File

@ -4,6 +4,7 @@ date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
require __DIR__ . '/../../src/_autoload.php';
require __DIR__ . '/../../sql_config.php';
use \pvv\side\Agenda;
?>
<html lang="no">
<title>Sosialverkstedet</title>
@ -36,7 +37,7 @@ $nextEvent = $activity->getNextEventFrom(new DateTimeImmutable);
<ul class="subtext">
<li>Tid:
<strong>
<?= $nextEvent->getStart()->format('Y-m-d H:i');?>
<?= Agenda::getFormattedDate($nextEvent->getStart());?>
</strong>
<li>Sted:
<strong>

View File

@ -4,6 +4,7 @@ date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
require __DIR__ . '/../../src/_autoload.php';
require __DIR__ . '/../../sql_config.php';
use \pvv\side\Agenda;
?>
<html lang="no">
<title>Sosialverkstedet</title>
@ -37,7 +38,7 @@ $nextEvent = $activity->getNextEventFrom(new DateTimeImmutable);
<ul class="subtext">
<li>Tid:
<strong>
<?= $nextEvent->getStart()->format('Y-m-d H:i');?>
<?= Agenda::getFormattedDate($nextEvent->getStart());?>
</strong>
<li>Sted:
<strong>