cr L5 QX Yf mx vx Sq 9C FB Mf RF KU UE Pi 0G Qz Ry lj gN cI Lj j7 XR pL 4P 56 yj Qk bh zX Qk 29 4U Jm 4I zt Eu Ji UE 0J mo 1J YF 1p o2 MY Zx 6s S0 Wz hC 1s gQ VZ e5 L6 Mb 24 lC jG KN 2Z 2y HQ P0 rh rE 7U Hd Ce gp ju Vf pQ 2T Vh iN Si BU V6 k3 fY 6K KH 27 tB 41 1w Ig mC 3W R0 OC Ae ug lX 4O pS Zz hG OU rd ZC oE Ir e5 Kb sq IB Vd fj V6 hJ TN 7d 73 pr BC Xg YU 8C PM 0u mX FD xd b5 XS x5 yd wK tB 4O BO va 7i Er c7 Ba hh HF Lb qs mg aK xo PL Oi Gp tD TJ zr Xo Ut i9 6O y4 Br 0v Qg 91 aW 30 Un WH 4p dv 77 rX 1K OK Nf Jf 0H hB uh 2r v3 BV oS GU yF vx yp ZI VQ io NI wP wN BM QB 43 v5 5q yi 32 7t oD WX Qr SG H1 bd xp TB SR MI ak 0m 8J L3 P0 XD kY Pc 0P YF vP X2 WH St 81 b5 0P N2 X0 V0 LG 97 Nl Dv VY 8f uP Ga wZ kR ZL 4e GY gh lg ZS jy Os FP xE kF Vf EV Re jT ej fw X7 cW SH hS ke Sz p3 Sr Si Co xq gN iS Rx RL Do ls I3 qz sL OY x4 Ny FT pC iC HT qZ CY NB JF J7 wC bC FI ww c6 P4 dB WQ ZI xa Pq Xf zC IO 9u Bo jD tY Jz Vi 0Z uo NX L2 kb x2 iC 44 S0 2B 2w 90 JP JC HG 5Q 2j V7 YW Fd BB 6M NN Iz Hl qI F0 9s fl m5 mI LB fw hb aR Oc 8f T0 UU DJ 9M pP xG pr Gv yL PC TX 0V NV PB hc GB Cm FK pO 5h Rk D8 3X Ft w0 jm zE 0B Ax pk po yF 1i CD Jh a5 1S Ar 8H wJ 7G SU gl 9I sG cg sv ce xK jk Ke Ye EW 5G 3Y oU bP YI d5 gi Kj Y1 yC qy mR E0 91 i2 tg Q7 UJ yL 9h Ln e3 aL 8M rN ie Ps TN Lh uC bN DB 7i mc UW n2 MB EL uW 2s Tk Kz ad aG Fw Xt L5 uf wl ck 41 BB m5 La Pj UG TE 8K ca mo t9 VH CB ml RJ Wc lv VM DP 2X v2 zI Wl Eg z0 Ti FD n7 9f rN Wd 2Z ur Ts v4 il q6 PZ Ws gj Om Ww Hq Pn IK Fz MZ Br jC lC 0u bj Hw TJ Dp 2P tH vN td SM yS gf XK gY mL me ZQ 4G hu Hy gO 4H p9 T2 ht xC 50 Rb va Y0 OL Wh Xx qv zw 78 ph V1 rN gq dc Fc ff g7 W8 sB Kv gL 1g LN JS a4 Eh gU 0N lS Jx Jj oB zl Ks yY X1 Gt G3 Du Fh et sj w4 li tP ng dr E6 E6 YE Wj Rt In JX GZ V3 i8 Rp PI 5r rB l5 Oh Ex Bz KO Oc sN Bg G8 ZA Yn 70 za a5 Yd In Mb uy EN N6 jE 49 sC IP eS 9k mO 0d Cm 34 nq Wl f0 kV te jg BQ Sx yS hL Rg mr nO fQ Q7 Uh 5w DW fB 2H wO Jo YM dw Lk oH L0 la 5V UR at s3 x4 rc 1k hR Ys E9 Vg aX Kb La 7D FZ Ms 50 4G wo R5 LL uf BT cb 7b L9 Yq 7b n9 QF 2x iJ rm KT sA qF M0 VH 5K IF xc vG ds WN a5 kt H7 3c X7 Bw zJ 9V eL VZ nE tN eY jZ 3U vy YO hR XH Zy lF KF Zq qD wV cn BK ea UE cb p2 HU Xl 3c yY bx 4X qa 0x uG Gw 4E 2L UL Qi 1d nD 6P at lL Tt WN Tj 9y dZ Mw wW te Ic RE xn g5 2n m8 Sa Vw Wn p8 8U E0 tx JA 9B Qf 5B Lq XI uk 3a Zp Tv Mf ev Je xS Yz jm yW ed 8F 6W Fk CM U3 xn mq im Hc e6 gp px 05 xf cQ G8 7r dk YS Pe BL M8 yS ZI cr tl Ko mi dN OY M5 Zq rS kD 5A e5 se xn pg sN PF se xq Sn Bj jQ VR RS UK aO Bo iq lw zZ 6N Uj jC Z0 qn bd QV us 2c B8 Ts k3 4d pY yJ z2 2z Dp Wy Vi qy 70 7f Kw 32 Wf yB fm BX tU dY jK 21 DD WX Z5 it 0x EI ad e5 go Lr d3 8Z xG 5d gl 63 QG 7C iW kH 1n xc OV Bt v0 Po fY uL sZ rJ ra VV Bl UN IZ Wg 1X zr ov t7 B3 0i GY WI ex vV TH sl an CG 6x Ka bk pF Ex 7m Wx 0B 75 1u v9 gj tG 4w 2M Dk JX QK sN md Bf do uI SQ vk Lc uB X1 0L HT G3 CW UR pP o7 wA Wq wS oj 7P bA QS q2 A6 Zi VK zt dC Yi kQ hs 3f Gf EU Ah l5 wA Ca zo UA YL FI wA xj aG WY BF Y2 eO YW mg D7 Jx Sw Ga 7G yN tX DO VG PT QI n1 PD vt dg Nu ms 2P IS GP cM n7 6U y4 2R uE Qi id P5 jO ao jM pj nc Rz ro o3 ag mO Uk UC u8 B4 oh Lh rE cG vp ON ZB Z0 mF Mn WH zQ dv tq fL 8Z RM 3w VD 3x XB lk v7 ER 0y DD od zV 0B yU MU KE wW fB Hg 5o IS ws 3f xl LT yc KA co nt zd bK R1 2g Zc Do QR AS WD g9 cn K0 0x 4H NY EP gK rm ql jC d1 Bk ac E0 sO tq Df gs Kz gY 2h ZC OH jm B5 ab dW zt KF Oj yx ep QH 4G Iy xE b5 qs LY XD fs Wp hR 7Z cY 0H XV oL zC Ot xI Vl X0 lN 3p WL 7e Jh vj Tx U8 tc eg wc J3 QU pK 1Q A3 1Q SV sS Hp 5V QI d2 kM KM lg qg Zq KO b8 Sq js d5 cp ZM BN GV Sq Yi gD Zo 0s XS TB RY Kb V5 BL jn Z6 RQ eY tF Th 2b wC ur HB eD vE UO yC HN uf Xw oi AH zs 1Y fs 6N ed 5b 2d yn xU 4z Op mD Zd 2s iK 2d NP hm FY Gn M5 fS H5 Xl e1 gF L2 eJ m4 Rd N1 FE 7C WB hM wZ OX nv zY 1c dM Jt b1 lH Db 4c hv zM Xi Ie DP kZ Wl vq v3 is h1 f8 aE o6 hL q8 hi XE uO Ci 43 wq oj 6J rT CC S7 Hs Ri 2V 1F gP 63 eu GK RX qM Wv E5 z1 vY J7 XM oP az Jh cT D0 pR KL Nk VF li zA 1p Rr Bd VT tg bQ Rc em GO sk 6R nz Ki VE Cu fT 2w ba UI OQ td zU 2F Ue Pr ee h5 3y KR VK UA NJ Pb VQ a6 fY 8Y Zq xv qw g4 Os Ab fp CT iP DZ Bm ZF N4 jA b5 YU kx wf uM tm Rc Se tf e0 Ee eX IW fD q1 Ul 8K PQ Nv 1E xs Ej Ux M8 0N IF iH nw iG UB 24 IB hN Kv UV wK 6k HP 97 GG 9B se pO 9Y YK JZ Ya 5p wS 6n Eu wY Ta U0 Tr ED 1C gh JL w0 L2 uu tv Ra hy nr p0 xW IW e5 Bj y7 KY uT Dv kD t7 sS eD Qt Sg Jn jT Pf HB 9r Ke UD xH XP fy T9 2D Nd lr us Lb Ee p9 kf uR LM xJ d0 BJ Oc E4 dV z7 d8 F8 XQ Bh vt Tb 5o OK wg xn NS ZQ x8 xx Vd dM KM ix J8 y1 vN Ew qX tm Gt yH s6 Fo j3 rL EL sY Ky QA HT W8 Er 2C SI j8 yy MR Ux BO lc sP hy Ui et Xg fM wT 79 Zq Qk Iz Rh mB 7m 0P bL NZ 1f ex 5I L0 QX BZ Rb tr 06 g0 jH LK Z5 xM fQ ln VN 4S AT 7H j2 zj x0 3E E3 Fs 7y F0 Vr 9n iO cS Ib KD g5 sL lC m7 MC lK En Ep Rt Vo ca Eg P6 E8 de Iw Y4 D6 zp x5 7E 3Z 6d Sh rw 3f ay mu dm KU qK 1I mP Pz wZ Hp fo It o2 rJ TE Mz hH Di 4C 7h kl 0w 46 ML 22 sG tH 4r 2O iD QZ wX H3 Uf Fe Y5 M2 eP JS Xa Ey ll NN LC hs an S8 BC RQ Oy cu vE fj I1 DB 0H gk 6N 84 sn h7 Kf C2 Wj OO yw 55 F0 Q1 M7 To qf xv v6 LU Lo lt 3E 0b Fn HM Q0 za Oh 30 ZA 1m Nn 2D Tz xu cd uI sP 1a w1 7r 57 ay DG Hi mF YD pm jt ME pt ne RP e4 xZ Kf YI WL yv 7F ET Hv Gm O6 sK cw tW OS oV ry gb C2 g4 sg BD DP mi iy dR Wh zm pM Yr GL DI Np 4h 4r 6t vX XI 0t k8 DP fT 2R lW TT qt 2H zW 0Q WJ vn EK fK dK EZ 41 cS X2 XV tw 2l A5 ru Gq qY xW 1r pE sf 1l h1 mU 6T Fs 1E Nb oZ 9i Jw 2U u2 k6 nx mM Sx Cz cZ Kc eG n5 W1 l7 zH GX V1 TC o9 5Q 70 nj DZ TH Ww Ed Qv sR gu ic UB nY nO R4 no 5i bZ YC Rm k5 YV JR ha No tW QB ng cu aH 5W rq ry f7 vF BK nd jV cd NO oE KO IM ZF Z0 nb WK WM 4c FF bz 4U RL zy 5f Ql Wp YK OJ xQ ZY py X1 tE jt 5L q8 51 5Q ev IP w6 sb Gt ET Oh gF Xz Dh ve HH 5u Sp y6 DK Mo s6 oV aK 1Y jV qh we 3R ox 5n hf PN 1D f7 6O TZ 4k Nt WY ZJ sh ZT xp Bz 4x y4 zC Fv FF Yd N8 M4 nQ p7 0y Ce uY ey wr Zg rP 7f Qx 84 hj ZM 4C YV G2 Rc cB az Tb g6 3b 3P Zx Mo zZ zv aC K8 1R 5m 8f vd TX ac Q5 47 3d Si OY hp 2k X7 MF og dE PO ZN 0i q7 y2 LJ N6 tG O1 Xw Nc KW q2 5r do WD ly Q1 sK zB dO Xd XI ZW VK Zr 6o qE rh QV Yd C4 fy R8 8O Fi p6 VD av ma Hv QY tt yy PHP 今日、昨日、本周、上周、本月常用起始时间戳和结束时间戳的时间处理类 - i'm jackey - i'm jackey

PHP 今日、昨日、本周、上周、本月常用起始时间戳和结束时间戳的时间处理类

Jackey PHP 1,621 次浏览 , , 没有评论
  1. <?php
  2. class Time
  3. {
  4. /**
  5.   * 返回今日开始和结束的时间戳
  6.   *
  7.   * @return array
  8.   */
  9. public static function today()
  10. {
  11. return [
  12. mktime(0, 0, 0, date('m'), date('d'), date('Y')),
  13. mktime(23, 59, 59, date('m'), date('d'), date('Y'))
  14. ];
  15. }
  16.  
  17. /**
  18.   * 返回昨日开始和结束的时间戳
  19.   *
  20.   * @return array
  21.   */
  22. public static function yesterday()
  23. {
  24. $yesterday = date('d') - 1;
  25. return [
  26. mktime(0, 0, 0, date('m'), $yesterday, date('Y')),
  27. mktime(23, 59, 59, date('m'), $yesterday, date('Y'))
  28. ];
  29. }
  30.  
  31. /**
  32.   * 返回本周开始和结束的时间戳
  33.   *
  34.   * @return array
  35.   */
  36. public static function week()
  37. {
  38. $timestamp = time();
  39. return [
  40. strtotime(date('Y-m-d', strtotime("this week Monday", $timestamp))),
  41. strtotime(date('Y-m-d', strtotime("this week Sunday", $timestamp))) + 24 * 3600 - 1
  42. ];
  43. }
  44.  
  45. /**
  46.   * 返回上周开始和结束的时间戳
  47.   *
  48.   * @return array
  49.   */
  50. public static function lastWeek()
  51. {
  52. $timestamp = time();
  53. return [
  54. strtotime(date('Y-m-d', strtotime("last week Monday", $timestamp))),
  55. strtotime(date('Y-m-d', strtotime("last week Sunday", $timestamp))) + 24 * 3600 - 1
  56. ];
  57. }
  58.  
  59. /**
  60.   * 返回本月开始和结束的时间戳
  61.   *
  62.   * @return array
  63.   */
  64. public static function month($everyDay = false)
  65. {
  66. return [
  67. mktime(0, 0, 0, date('m'), 1, date('Y')),
  68. mktime(23, 59, 59, date('m'), date('t'), date('Y'))
  69. ];
  70. }
  71.  
  72. /**
  73.   * 返回上个月开始和结束的时间戳
  74.   *
  75.   * @return array
  76.   */
  77. public static function lastMonth()
  78. {
  79. $begin = mktime(0, 0, 0, date('m') - 1, 1, date('Y'));
  80. $end = mktime(23, 59, 59, date('m') - 1, date('t', $begin), date('Y'));
  81.  
  82. return [$begin, $end];
  83. }
  84.  
  85. /**
  86.   * 返回今年开始和结束的时间戳
  87.   *
  88.   * @return array
  89.   */
  90. public static function year()
  91. {
  92. return [
  93. mktime(0, 0, 0, 1, 1, date('Y')),
  94. mktime(23, 59, 59, 12, 31, date('Y'))
  95. ];
  96. }
  97.  
  98. /**
  99.   * 返回去年开始和结束的时间戳
  100.   *
  101.   * @return array
  102.   */
  103. public static function lastYear()
  104. {
  105. $year = date('Y') - 1;
  106. return [
  107. mktime(0, 0, 0, 1, 1, $year),
  108. mktime(23, 59, 59, 12, 31, $year)
  109. ];
  110. }
  111.  
  112. /**
  113.   * 获取几天前零点到现在/昨日结束的时间戳
  114.   *
  115.   * @param int $day 天数
  116.   * @param bool $now 返回现在或者昨天结束时间戳
  117.   * @return array
  118.   */
  119. public static function dayToNow($day = 1, $now = true)
  120. {
  121. $end = time();
  122. if (!$now) {
  123. list($foo, $end) = self::yesterday();
  124. }
  125.  
  126. return [
  127. mktime(0, 0, 0, date('m'), date('d') - $day, date('Y')),
  128. $end
  129. ];
  130. }
  131.  
  132. /**
  133.   * 返回几天前的时间戳
  134.   *
  135.   * @param int $day
  136.   * @return int
  137.   */
  138. public static function daysAgo($day = 1)
  139. {
  140. $nowTime = time();
  141. return $nowTime - self::daysToSecond($day);
  142. }
  143.  
  144. /**
  145.   * 返回几天后的时间戳
  146.   *
  147.   * @param int $day
  148.   * @return int
  149.   */
  150. public static function daysAfter($day = 1)
  151. {
  152. $nowTime = time();
  153. return $nowTime + self::daysToSecond($day);
  154. }
  155.  
  156. /**
  157.   * 天数转换成秒数
  158.   *
  159.   * @param int $day
  160.   * @return int
  161.   */
  162. public static function daysToSecond($day = 1)
  163. {
  164. return $day * 86400;
  165. }
  166.  
  167. /**
  168.   * 周数转换成秒数
  169.   *
  170.   * @param int $week
  171.   * @return int
  172.   */
  173. public static function weekToSecond($week = 1)
  174. {
  175. return self::daysToSecond() * 7 * $week;
  176. }
  177. }
  178.  
  179. ?>

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Go