TestTime.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 2017/5/25
  6. * Time: 上午10:21
  7. */
  8. define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
  9. require_once(BASE_ROOT_PATH . '/fooder.php');
  10. require_once(BASE_ROOT_PATH . '/helper/stat_helper.php');
  11. require_once(BASE_ROOT_PATH . '/helper/stat_helper.php');
  12. require_once(BASE_ROOT_PATH . '/helper/util_helper.php');
  13. class TestTime extends PHPUnit_Framework_TestCase
  14. {
  15. public static function setUpBeforeClass()
  16. {
  17. Base::run_util();
  18. }
  19. public function testS()
  20. {
  21. $tm = strtotime('2017-08-01 3:43:00');
  22. $tm1 = strtotime('2017-8-01 3:43:00');
  23. $tm2 = strtotime('2017-08-1 3:43:00');
  24. $tm3 = strtotime('2017-8-1 3:43:00');
  25. $tm3 = strtotime('2017-8-1 03:43:00');
  26. $tm3 = strtotime('2017-8-1 3:43:00');
  27. $tm3 = strtotime('2017-8-1 3:43');
  28. }
  29. public function testDay()
  30. {
  31. $date = date('Y-m-d',time());
  32. $this->mStartm = strtotime(date('Y-m-d',time()));
  33. $this->mEndtm = $this->mStartm + 86400 - 1;
  34. }
  35. public function testWeek()
  36. {
  37. $date = date('Y-m-d',time());
  38. $cur_time = strtotime(date('Y-m-d',time())) + 86400;
  39. $start = $cur_time - 86400 * 7;
  40. $end = $cur_time -1;
  41. $v = ($end - $start + 1) / 86400;
  42. }
  43. public function testMonth()
  44. {
  45. $cur = time();
  46. $cur_date = new DateTime();
  47. $cur_date->setTimestamp($cur);
  48. $inter = new DateInterval('P1M');
  49. $cur_date->sub($inter);
  50. $time = $cur_date->getTimestamp();
  51. }
  52. public function testLastsec()
  53. {
  54. $expried_secs = 10 * 24 * 3600;
  55. $usable_time = time() + $expried_secs;
  56. $cur_date = date('Y-m-d H:i:s',$usable_time);
  57. $cur_time = strtotime(date('Y-m-d',$usable_time)) + 86399;
  58. $curx_date = date('Y-m-d H:i:s',$cur_time);
  59. $cur_time = util::last_day_secs($usable_time);
  60. $cury_date = date('Y-m-d H:i:s',$cur_time);
  61. $delta = $usable_time - $cur_time;
  62. }
  63. public function testMtrand()
  64. {
  65. for ($i = 0; $i < 100; $i++) {
  66. echo mt_rand(0,6);
  67. echo "\n";
  68. }
  69. }
  70. }