首页 > PHP开源 > 获得一天,小时,分钟所包含的秒,分,小时–kohana3使用手册

获得一天,小时,分钟所包含的秒,分,小时–kohana3使用手册

2011年4月26日 发表评论 阅读评论

Date::seconds()方法将会返回一个数组,该数组包括了1分钟内的秒数递增集合。

用法

Date::seconds();

将返回

Array ( [0] => 00 [1] => 01 [2] => 02 [3] => 03 [4] => 04 [5] => 05 [6] => 06 [7] => 07 [8] => 08 [9] => 09 [10] => 10 [11] => 11 [12] => 12 [13] => 13 [14] => 14 [15] => 15 [16] => 16 [17] => 17 [18] => 18 [19] => 19 [20] => 20 [21] => 21 [22] => 22 [23] => 23 [24] => 24 [25] => 25 [26] => 26 [27] => 27 [28] => 28 [29] => 29 [30] => 30 [31] => 31 [32] => 32 [33] => 33 [34] => 34 [35] => 35 [36] => 36 [37] => 37 [38] => 38 [39] => 39 [40] => 40 [41] => 41 [42] => 42 [43] => 43 [44] => 44 [45] => 45 [46] => 46 [47] => 47 [48] => 48 [49] => 49 [50] => 50 [51] => 51 [52] => 52 [53] => 53 [54] => 54 [55] => 55 [56] => 56 [57] => 57 [58] => 58 [59] => 59 )

你也可以随意的设置起点和终点值以及一个递增的步进。

Date::seconds(2, 10, 30);

将返回

Array ( [10] => 10 [12] => 12 [14] => 14 [16] => 16 [18] => 18 [20] => 20 [22] => 22 [24] => 24 [26] => 26 [28] => 28 )

获得一小时内的分钟数量

Date::minutes()方法会返回一个数组,该数组包括了1小时内的分钟的递增集合。Date::minutes()使用的默认步进式5

Date::minutes();

将返回

Array ( [0] => 00 [5] => 05 [10] => 10 [15] => 15 [20] => 20 [25] => 25 [30] => 30 [35] => 35 [40] => 40 [45] => 45 [50] => 50 [55] => 55 )

Date::minutes(10);

将返回

Array ( [0] => 00 [10] => 10 [20] => 20 [30] => 30 [40] => 40 [50] => 50 )

获得一天内的小时数量

Date::hours()方法会返回一个数组,该数组包括了1天内的小时的递增集合。

Date::hours()

将返回

Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 [10] => 10 [11] => 11 [12] => 12 )

设置第2个元素为TRUE,则是24小时

Date::hours(1, TRUE);

将返回

Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 [10] => 10 [11] => 11 [12] => 12 [13] => 13 [14] => 14 [15] => 15 [16] => 16 [17] => 17 [18] => 18 [19] => 19 [20] => 20 [21] => 21 [22] => 22 [23] => 23 )

变换步进以及设置一个开始的小时

Date::hours(2, TRUE, 10);

将返回

Array ( [10] => 10 [12] => 12 [14] => 14 [16] => 16 [18] => 18 [20] => 20 [22] => 22 )

分类: PHP开源 标签:
  1. 本文目前尚无任何评论.