Completed
Push — master ( 4e56c1...a65fb9 )
by Tim
47s queued 10s
created

FormatUtcDateViewHelper::initializeArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Provide strftime function in UTC context.
5
 */
6
declare(strict_types=1);
7
8
namespace HDNET\Calendarize\ViewHelpers\DateTime;
9
10
use TYPO3\CMS\Fluid\ViewHelpers\Format\DateViewHelper;
11
12
/**
13
 * Formats the date to UTC.
14
 */
15
class FormatUtcDateViewHelper extends DateViewHelper
16
{
17
    /**
18
     * Format dateTime to the UTC timezone.
19
     *
20
     * @return string
21
     */
22
    public function render()
23
    {
24
        // save configured timezone
25
        $timezone = date_default_timezone_get();
26
        // set timezone to UTC
27
        date_default_timezone_set('UTC');
28
29
        $result = parent::render();
30
31
        // restore timezone setting
32
        date_default_timezone_set($timezone);
33
34
        return $result;
35
    }
36
}
37