ILIAS
trunk Revision v11.0_alpha-1846-g895b5f47236
◀ ilDoc Overview
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
+
Variables
$
c
e
g
h
j
l
m
p
s
t
u
v
+
Enumerations
a
c
e
f
i
j
l
m
n
o
p
r
s
t
u
v
z
+
Enumerator
a
c
d
e
f
g
i
l
m
n
o
p
q
s
t
u
v
y
+
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
+
Data Fields
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Ö
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Ö
Enumerations
Enumerator
+
Files
File List
+
Globals
+
All
$
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
z
+
Functions
a
b
c
d
e
f
g
h
i
m
n
p
r
s
t
u
v
+
Variables
$
a
c
e
g
h
i
m
n
o
p
r
s
t
u
v
z
Enumerations
Enumerator
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Enumerations
Enumerator
Modules
Pages
ChangeTimezone.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
namespace
ILIAS\Refinery\DateTime
;
22
23
use
ILIAS\Refinery\DeriveApplyToFromTransform
;
24
use
ILIAS\Refinery\Transformation
;
25
use
ILIAS\Refinery\DeriveInvokeFromTransform
;
26
use
DateTimeZone
;
27
use
InvalidArgumentException
;
28
use
DateTimeImmutable
;
29
34
class
ChangeTimezone
implements
Transformation
35
{
36
use
DeriveApplyToFromTransform
;
37
use
DeriveInvokeFromTransform
;
38
39
private
DateTimeZone
$timezone
;
40
41
public
function
__construct
(
string
$timezone)
42
{
43
if
(!in_array($timezone, timezone_identifiers_list(),
true
)) {
44
throw
new
InvalidArgumentException
(
"$timezone is not a valid timezone identifier"
, 1);
45
}
46
$this->timezone =
new
DateTimeZone
($timezone);
47
}
48
52
public
function
transform
($from):
DateTimeImmutable
53
{
54
if
(!$from instanceof
DateTimeImmutable
) {
55
throw
new
InvalidArgumentException
(
"$from is not a DateTimeImmutable-object"
, 1);
56
}
57
58
$ts = $from->format(
'Y-m-d H:i:s'
);
59
60
return
new
DateTimeImmutable($ts, $this->timezone);
61
}
62
}
DateTime\ChangeTimezone\__construct
__construct(string $timezone)
Definition:
ChangeTimezone.php:41
DateTimeImmutable
DateTimeZone
ILIAS\Refinery\DeriveInvokeFromTransform
trait DeriveInvokeFromTransform
Definition:
DeriveInvokeFromTransform.php:24
ILIAS\Refinery\DeriveApplyToFromTransform
trait DeriveApplyToFromTransform
Definition:
DeriveApplyToFromTransform.php:29
Transformation
DateTime\ChangeTimezone\transform
transform($from)
Definition:
ChangeTimezone.php:52
DateTime\ChangeTimezone\$timezone
DateTimeZone $timezone
Definition:
ChangeTimezone.php:39
ILIAS\Refinery\DateTime
Definition:
ChangeTimezone.php:21
InvalidArgumentException
DateTime\ChangeTimezone
Change the timezone (and only the timezone) of php's WITHOUT changing the date-value.
Definition:
ChangeTimezone.php:34
components
ILIAS
Refinery
src
DateTime
ChangeTimezone.php
Generated on Mon Apr 21 2025 23:03:19 for ILIAS by
1.8.13 (using
Doxyfile
)