Przeglądaj źródła

Add helper friendly_date_time_short()

Vijayakrishnan Krishnan 4 lat temu
rodzic
commit
3c89d7974b
1 zmienionych plików z 14 dodań i 0 usunięć
  1. 14 0
      app/Helpers/helpers.php

+ 14 - 0
app/Helpers/helpers.php

@@ -28,6 +28,20 @@ if(!function_exists('friendly_date_time')) {
     }
 }
 
+if(!function_exists('friendly_date_time_short')) {
+    function friendly_date_time_short($value, $includeTime = true, $default = '-') {
+        if(!$value || empty($value)) return $default;
+        try {
+            $result = strtotime($value);
+            $result = date("m/d/y" . ($includeTime ? ", h:ia" : ""), $result);
+            return $result;
+        }
+        catch (Exception $e) {
+            return $value;
+        }
+    }
+}
+
 if(!function_exists('friendly_time')) {
     function friendly_time($value, $default = '-') {
         if(!$value || empty($value)) return $default;