1 <?php
2
3 4 5 6 7 8 9
10
11 12 13 14 15 16 17 18 19 20
21 class sfDateTimeToolkit
22 {
23 24 25 26 27 28
29 public static function breakdown($ts = null)
30 {
31
32 if ($ts === null) $ts = sfDateTimeToolkit::now();
33
34
35 $H = date('H', $ts);
36 $i = date('i', $ts);
37 $s = date('s', $ts);
38 $m = date('m', $ts);
39 $d = date('d', $ts);
40 $Y = date('Y', $ts);
41
42 return array($H, $i, $s, $m, $d, $Y);
43 }
44
45 46 47 48 49 50 51
52 public static function now()
53 {
54 return time();
55 }
56
57 58 59 60 61
62 public static function getTS($value = null)
63 {
64 if ($value === null)
65 {
66 return sfDateTimeToolkit::now();
67 }
68 else if ($value instanceof sfDate)
69 {
70 return $value->get();
71 }
72 else if (!is_numeric($value))
73 {
74 return strtotime($value);
75 }
76 else if (is_numeric($value))
77 {
78 return $value;
79 }
80
81 throw new sfDateTimeException(sprintf('A timestamp could not be retrieved from the value: %s', $value));
82 }
83 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-