Conditions | 5 |
Paths | 2 |
Total Lines | 11 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
11 | public function Nice() { |
||
12 | //instantiate new DateTime object based off received timestamp in the default timezone |
||
13 | $timestamp = new DateTime($this->value, new DateTimeZone(date_default_timezone_get())); |
||
14 | //if a user is logged in, has set a timezone that is in the allowed list and |
||
15 | //that timezone is NOT the default one then convert the timestamp to use the selected timezone |
||
16 | if(Member::currentUserID() && isset(Member::CurrentUser()->Timezone) && in_array(Member::CurrentUser()->Timezone, timezone_identifiers_list()) && Member::CurrentUser()->Timezone != date_default_timezone_get()){ |
||
17 | $timestamp->setTimezone(new DateTimeZone(Member::CurrentUser()->Timezone)); |
||
18 | } |
||
19 | //return timestamp in "Nice" format + the user's timezone |
||
20 | return $timestamp->Format('d/m/Y g:ia'); |
||
21 | } |
||
22 | } |
||
23 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.