123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- * Description of Time
- *
- * @author jgao
- */
- class Time {
- //put your code here
-
- /**
- * 获取服务端的本地时间戳
- * 客户端时间同步,这个是后期加密算法的关键
- * @param type $offset 时间偏移:用于某些服务端有必要出现时间偏差的情况
- * @return type
- */
- static function now($offset=0){
- return time() + $offset;
- }
-
- /**
- * 获取当前小时数
- * @param type $time
- * @return type
- */
- static function hours($time=-1){
- if($time<0){
- $time = TimeUtil::tsCurrent();
- }
- return CommUtil::floatToInt($time/3600); // 东八区前提8小时时差
- }
-
- /**
- * 获取当前天数
- * 检测玩家连续登录及隔天刷新操作用
- * @param type $time 当前时间戳
- * @return type
- */
- static function days($time=-1){
- if($time<0){
- $time = TimeUtil::tsCurrent();
- }
- return CommUtil::floatToInt(($time + 28800)/86400); // 东八区前提8小时时差
- }
-
- /**
- * 获取当前的周目数
- * @param type $time
- * @return type
- */
- static function weeks($time=-1){
- return CommUtil::floatToInt((TimeUtil::tsDay($time)+3)/7);
- }
-
- /**
- * 获取当前的日期时间
- * @return \Date
- */
- static function date($time=0){
- return new Date($time);
- }
-
- }
|