Browse Source

date parse util

tags/0.1.5^0
Robin Thoni 9 years ago
parent
commit
0316347b32
1 changed files with 11 additions and 0 deletions
  1. 11
    0
      src/Utils/LuStringUtils.php

+ 11
- 0
src/Utils/LuStringUtils.php View File

@@ -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…
Cancel
Save