Add countdown logic

This commit is contained in:
Vencislav Atanasov 2024-10-25 00:09:41 +03:00
parent b28f8909f9
commit b0ea463d53
1 changed files with 16 additions and 4 deletions

View File

@ -4,9 +4,20 @@
<?php
e_('about_event');
// countdown begin
$eventStartTimes = [
'2024' => '2024-11-02 10:00:00',
];
$blog_slug = get_blog_slug();
if ($blog_slug === '2024') {
if (array_key_exists($blog_slug, $eventStartTimes)) {
$now = new DateTimeImmutable('now');
$eventStart = new DateTimeImmutable($eventStartTimes[$blog_slug] . ' Europe/Sofia');
$interval = $now->diff($eventStart);
}
if ($interval instanceof DateInterval && $interval->invert === 0) {
?>
<style>
.countdown {
@ -32,9 +43,9 @@ if ($blog_slug === '2024') {
<table>
<tbody>
<tr class="digits">
<td>08</td>
<td>10</td>
<td>21</td>
<td><?php echo $interval->format('%a'); ?></td>
<td><?php echo $interval->format('%H'); ?></td>
<td><?php echo $interval->format('%I'); ?></td>
</tr>
<tr class="units">
<td><?php e_('countdown_days'); ?></td>
@ -47,6 +58,7 @@ if ($blog_slug === '2024') {
</div>
<?php
}
// countdown end
?>
</section>
<section class="content">