本文出至:学新通博客
<?php /** * 输出html标签 * @param string $label 标签 */ function h(string $label = 'b'): void { switch ($label) { case 'b': echo '<br/>'; break; case 'h': echo '<hr/>'; break; } } /** * 打印函数 * @param string $str 字符串 * @param string $label 分隔符 */ function e(string $str = '', string $label = 'b'): void { echo $str; h($label); } e('当前时间'); e(date('Y-m-d H:i:s', time()) . ' // 当前时间'); e(date('Y-m-d H:i:s', strtotime('now')) . ' // 当前时间<br/>'); e('今天、昨天、明天'); e(date('Y-m-d H:i:s', strtotime('today')) . ' // 今天0点'); e(date('Y-m-d H:i:s', strtotime('yesterday')) . ' // 昨天0点'); e(date('Y-m-d H:i:s', strtotime('tomorrow')) . ' // 明天0点<br/>'); e('星期一到星期天: Monday Tuesday Wednesday Thursday Friday Saturday Sunday', '<br/><br/>'); e('周一'); e(date('Y-m-d H:i:s', strtotime('this week')) . ' // 本周一当前时间'); e(date('Y-m-d H:i:s', strtotime('Monday this week')) . ' // 本周一0点'); e(date('Y-m-d H:i:s', strtotime('Mon this week')) . ' // 本周一0点<br/>'); e('周三'); e(date('Y-m-d H:i:s', strtotime('Wednesday this week')) . ' // 本周三0点'); e(date('Y-m-d H:i:s', strtotime('Wed this week')) . ' // 本周三0点<br/>'); e(date('Y-m-01 H:i:s') . ' // 本月第一天0点'); e(date('Y-01-01 00:00:00') . ' // 本年第一天0点<br/>'); e('周,天,小时,分,秒 【注意:可以使用复数或者单数(即加‘s’或不加‘s’)】'); e(date('Y-m-d H:i:s', strtotime('1 week 3 days 7 hours 5 second')) . ' // 1 week 3 days 7 hours 5 second'); e(date('Y-m-d H:i:s', strtotime('1 week 7 hours 5 minute')) . ' // 1 week 7 hours 5 minute'); e(date('Y-m-d H:i:s', strtotime('1 week -3 days 1 hours 10 second')) . ' // 1 week -3 days 1 hours 10 second<br/>'); // 注意大小月 注意:可以使用复数或者单数(即加‘s’或不加‘s’) e('指定日期上月,上月最后一天,下月,下月第一天 【注意:可以使用复数或者单数(即加‘s’或不加‘s’)】'); e(date('Y-m-d H:i:s', strtotime('2020-03-31 -1 month')) . ' // 2020-03-31 -1 month'); e(date('Y-m-d H:i:s', strtotime('2020-03-31 last day of -1 month')) . ' // 2020-03-31 last day of -1 month'); e(date('Y-m-d H:i:s', strtotime('2020-08-31 +1 month')) . ' // 2020-08-31 +1 month'); e(date('Y-m-d H:i:s', strtotime('2020-08-31 first day of +1 month')) . ' // 2020-08-31 first day of +1 month<br/>'); e('下个星期四,上个星期一 【注意:这里不区分大小写,并且可以使用缩写】'); e(date('Y-m-d H:i:s', strtotime('next Thursday')) . ' // next Thursday'); e(date('Y-m-d H:i:s', strtotime('last Mon')) . ' // last Mon<br/>'); e('上两个星期二,下个星期三 【注意:这里不区分大小写,并且可以使用缩写】'); e(date('Y-m-d H:i:s', strtotime('-2 Tuesday')) . ' // -2 Tuesday'); e(date('Y-m-d H:i:s', strtotime('+1 Wed')) . ' // +1 Wed<br/>'); e('下年,上两年 【注意:可以使用复数或者单数(即加‘s’或不加‘s’)】'); e(date('Y-m-d H:i:s', strtotime('+1 years')) . ' // +1 years'); e(date('Y-m-d H:i:s', strtotime('-2 year')) . ' // -2 year<br/>'); e('下月,上两月 【注意:可以使用复数或者单数(即加‘s’或不加‘s’)】'); e(date('Y-m-d H:i:s', strtotime('+1 months')) . ' // +1 months'); e(date('Y-m-d H:i:s', strtotime('-2 month')) . ' // -2 month<br/>'); e('下一周,上两周 【注意:可以使用复数或者单数(即加‘s’或不加‘s’)】'); e(date('Y-m-d H:i:s', strtotime('+1 weeks')) . ' // +1 weeks'); e(date('Y-m-d H:i:s', strtotime('-2 week')) . ' // -2 week<br/>'); e('下一天,上两天 【注意:可以使用复数或者单数(即加‘s’或不加‘s’)】'); e(date('Y-m-d H:i:s', strtotime('+1 days')) . ' // +1 days'); e(date('Y-m-d H:i:s', strtotime('-2 day')) . ' // -2 day<br/>'); e('下小时,上两小时 【注意:可以使用复数或者单数(即加‘s’或不加‘s’)】'); e(date('Y-m-d H:i:s', strtotime('+1 hours')) . ' // +1 hours'); e(date('Y-m-d H:i:s', strtotime('-2 hour')) . ' // -2 hour<br/>'); e('下分钟,上两分钟 【注意:可以使用复数或者单数(即加‘s’或不加‘s’)】'); e(date('Y-m-d H:i:s', strtotime('+1 minutes')) . ' // +1 minutes'); e(date('Y-m-d H:i:s', strtotime('-2 minute')) . ' // -2 minute<br/>'); e('下秒钟,上两秒钟 【注意:可以使用复数或者单数(即加‘s’或不加‘s’)】'); e(date('Y-m-d H:i:s', strtotime('+1 seconds')) . ' // +1 seconds'); e(date('Y-m-d H:i:s', strtotime('-2 second')) . ' // -2 second<br/>'); e('星期后面加字母这种方式只能和(last/next)配合使用'); foreach (range('a', 'z') as $key => $value) { e(date('Y-m-d H:i:s', strtotime('last Mon' . $value)) . ' // last Mon' . $value); e(date('Y-m-d H:i:s', strtotime('last Monday' . $value)) . ' // last Monday' . $value); } e();
本文出至:学新通博客
标签:
版权声明:本站内容均来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
联系方式:wuliqiang_aa@163.com