Explorar el Código

date parse util

tags/0.1.5^0
Robin Thoni hace 8 años
padre
commit
0316347b32
Se han modificado 1 ficheros con 11 adiciones y 0 borrados
  1. 11
    0
      src/Utils/LuStringUtils.php

+ 11
- 0
src/Utils/LuStringUtils.php Ver fichero

@@ -8,6 +8,8 @@
8 8
 
9 9
 namespace Luticate\Utils;
10 10
 
11
+use Carbon\Carbon;
12
+
11 13
 
12 14
 class LuStringUtils
13 15
 {
@@ -40,4 +42,13 @@ class LuStringUtils
40 42
         $array = json_decode($json, true);
41 43
         return self::arraySnakeToCamelCase($array);
42 44
     }
45
+
46
+    public static function parseDate($str)
47
+    {
48
+        try {
49
+            return Carbon::parse($str);
50
+        } catch (\Exception $e) {
51
+            return null;
52
+        }
53
+    }
43 54
 }

Loading…
Cancelar
Guardar