Browse Source

Show timezone with friendly time

Vijayakrishnan 3 years ago
parent
commit
e928911ad5
2 changed files with 19 additions and 5 deletions
  1. 18 4
      app/Helpers/helpers.php
  2. 1 1
      resources/views/app/patient/appointments.blade.php

+ 18 - 4
app/Helpers/helpers.php

@@ -128,14 +128,21 @@ if(!function_exists('friendly_date_time')) {
     function friendly_date_time($value, $includeTime = true, $default = '-', $long_year=false) {
         if(!$value || empty($value)) return $default;
         try {
-            $result = strtotime($value);
+
+            $realTimezone = 'US/Eastern';
+            $date = new DateTime($value);
+            $date->setTimezone(new DateTimeZone($realTimezone));
+
+            return $date->format("m/d/y" . ($includeTime ? ", h:ia" : "")) . ($includeTime ? ' EST' : '');
+
+            /*$result = strtotime($value);
             if($long_year){
                 $result = date("m/d/Y" . ($includeTime ? ", h:ia" : ""), $result);
             }else{
                 $result = date("m/d/y" . ($includeTime ? ", h:ia" : ""), $result);
             }
 
-            return $result;
+            return $result;*/
         }
         catch (Exception $e) {
             return $value;
@@ -147,9 +154,16 @@ if(!function_exists('friendlier_date_time')) {
     function friendlier_date_time($value, $includeTime = true, $default = '-') {
         if(!$value || empty($value)) return $default;
         try {
-            $result = strtotime($value);
+
+            $realTimezone = 'US/Eastern';
+            $date = new DateTime($value);
+            $date->setTimezone(new DateTimeZone($realTimezone));
+
+            return $date->format("m/d/y" . ($includeTime ? ", h:ia" : "")) . ($includeTime ? ' EST' : '');
+
+            /*$result = strtotime($value);
             $result = date("m/d/Y" . ($includeTime ? ", h:i a" : ""), $result);
-            return $result;
+            return $result;*/
         }
         catch (Exception $e) {
             return $value;

+ 1 - 1
resources/views/app/patient/appointments.blade.php

@@ -39,7 +39,7 @@
                     <tr>
                         <td>
                             <a href="/patients/view/{{$patient->uid}}/calendar/{{$appointment->uid}}" class="text-nowrap">
-                                {{friendlier_date_time($appointment->raw_date . ' ' . $appointment->raw_start_time)}}
+                                {{friendlier_date_time($appointment->raw_date . ' ' . $appointment->raw_start_time)}} <span class="text-sm">{{friendly_timezone($appointment->timezone)}}</span>
                             </a>
                         </td>
                         <td>{{ $appointment->pro->displayName() }}</pre></td>