TestTime.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. $date = date('Y-m-d H:i:S',1517399862);
  22. $tm = strtotime('2017-08-01 3:43:00');
  23. $tm1 = strtotime('2017-8-01 3:43:00');
  24. $tm2 = strtotime('2017-08-1 3:43:00');
  25. $tm3 = strtotime('2017-8-1 3:43:00');
  26. $tm3 = strtotime('2017-8-1 03:43:00');
  27. $tm3 = strtotime('2017-8-1 3:43:00');
  28. $tm3 = strtotime('2017-8-1 3:43');
  29. }
  30. public function testDay()
  31. {
  32. $date = date('Y-m-d',time());
  33. $this->mStartm = strtotime(date('Y-m-d',time()));
  34. $this->mEndtm = $this->mStartm + 86400 - 1;
  35. }
  36. public function testWeek()
  37. {
  38. $date = date('Y-m-d',time());
  39. $cur_time = strtotime(date('Y-m-d',time())) + 86400;
  40. $start = $cur_time - 86400 * 7;
  41. $end = $cur_time -1;
  42. $v = ($end - $start + 1) / 86400;
  43. }
  44. public function testMonth()
  45. {
  46. $cur = time();
  47. $cur_date = new DateTime();
  48. $cur_date->setTimestamp($cur);
  49. $inter = new DateInterval('P1M');
  50. $cur_date->sub($inter);
  51. $time = $cur_date->getTimestamp();
  52. }
  53. public function testLastsec()
  54. {
  55. $expried_secs = 10 * 24 * 3600;
  56. $usable_time = time() + $expried_secs;
  57. $cur_date = date('Y-m-d H:i:s',$usable_time);
  58. $cur_time = strtotime(date('Y-m-d',$usable_time)) + 86399;
  59. $curx_date = date('Y-m-d H:i:s',$cur_time);
  60. $cur_time = util::last_day_secs($usable_time);
  61. $cury_date = date('Y-m-d H:i:s',$cur_time);
  62. $delta = $usable_time - $cur_time;
  63. }
  64. public function testMtrand()
  65. {
  66. for ($i = 0; $i < 100; $i++) {
  67. echo mt_rand(0,6);
  68. echo "\n";
  69. }
  70. }
  71. }