PluginProbe
WPIDE – File Manager & Code Editor / 3.5.9
WPIDE – File Manager & Code Editor v3.5.9
3.5.9 3.5.8 3.5.7 2.0.14 2.0.15 2.0.16 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.2 2.3 2.3.1 2.3.2 2.4.0 2.5 2.6 3.0 3.1 3.2 3.3 All 55 releases
wpide / vendor / rakit / validation / src / Rules / Traits / DateUtilsTrait.php

DateUtilsTrait.php in WPIDE – File Manager & Code Editor 3.5.9, at vendor/rakit/validation/src/Rules/Traits/DateUtilsTrait.php

44 lines 844 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Rakit\Validation\Rules\Traits;
4
5 use Exception;
6
7 trait DateUtilsTrait
8 {
9
10 /**
11 * Check the $date is valid
12 *
13 * @param string $date
14 * @return bool
15 */
16 protected function isValidDate(string $date): bool
17 {
18 return (strtotime($date) !== false);
19 }
20
21 /**
22 * Throw exception
23 *
24 * @param string $value
25 * @return Exception
26 */
27 protected function throwException(string $value)
28 {
29 // phpcs:ignore
30 return new Exception("Expected a valid date, got '{$value}' instead. 2016-12-08, 2016-12-02 14:58, tomorrow are considered valid dates");
31 }
32
33 /**
34 * Given $date and get the time stamp
35 *
36 * @param mixed $date
37 * @return int
38 */
39 protected function getTimeStamp($date): int
40 {
41 return strtotime($date);
42 }
43 }
44