打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
复杂的时间判断,搞得头疼,记住我的这些代码吧

<?php

$now = time();

//今天

$beginTime = date('Y-m-d 00:00:00', $now);

$endTime = date('Y-m-d 23:59:59', $now);

//昨天

$time_zuotian = strtotime('-1 day', $now);

$beginTime_zuotian = date('Y-m-d 00:00:00', $time_zuotian);

$endTime_zuotian = date('Y-m-d 23:59:59', $time_zuotian);

//本周

$time_benzhou = '1' == date('w') ? strtotime('Monday', $now) : strtotime('last Monday', $now);

$beginTime_benzhou = date('Y-m-d 00:00:00', $time_benzhou);

$endTime_benzhou = date('Y-m-d 23:59:59', strtotime('Sunday', $now));

//本月

$beginTime_benyue = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m', $now), '1', date('Y', $now)));

$endTime_benyue = date('Y-m-d 23:39:59', mktime(0, 0, 0, date('m', $now), date('t', $now), date('Y', $now)));

//半年

$time_bannian = strtotime('-5 month', $now);

$beginTime_bannian = date('Y-m-d 00:00:00', mktime(0, 0,0, date('m', $time_bannian), 1, date('Y', $time_bannian)));

$endTime_bannian = date('Y-m-d 23:39:59', mktime(0, 0, 0, date('m', $now), date('t', $now), date('Y', $now)));

//一年

$beginTime_yinian = date('Y-m-d 00:00:00', mktime(0, 0,0, 1, 1, date('Y', $now)));

$endTime_yinian = date('Y-m-d 23:39:59', mktime(0, 0, 0, 12, 31, date('Y', $now)));

//三年

$time_sannian = strtotime('-2 year', $now);

$beginTime_sannian = date('Y-m-d 00:00:00', mktime(0, 0, 0, 1, 1, date('Y', $time_sannian)));

$endTime_sannian = date('Y-m-d 23:39:59', mktime(0, 0, 0, 12, 31, date('Y')));

?>

<?php

//作者主页 https://www.bz80.vip

//今日询盘

$sql01 = "SELECT count(*) FROM jg_company where `jindushijian` >= unix_timestamp( '$beginTime' ) AND `jindushijian` <= unix_timestamp( '$endTime' ) and jindu=1";

$rs01 = $pdo->query($sql01)->fetchColumn();

$today_num01 = $rs01;

//今日报价

$sql02 = "SELECT count(*) FROM jg_company where `jindushijian` >= unix_timestamp( '$beginTime' ) AND `jindushijian` <= unix_timestamp( '$endTime' ) and jindu=2";

$rs02 = $pdo->query($sql02)->fetchColumn();

$today_num02 = $rs02;

//今日样品

$sql03 = "SELECT count(*) FROM jg_company where `jindushijian` >= unix_timestamp( '$beginTime' ) AND `jindushijian` <= unix_timestamp( '$endTime' ) and jindu=3";

$rs03 = $pdo->query($sql03)->fetchColumn();

$today_num03 = $rs03;

//今日定金

$sql04 = "SELECT count(*) FROM jg_company where `jindushijian` >= unix_timestamp( '$beginTime' ) AND `jindushijian` <= unix_timestamp( '$endTime' ) and jindu=5";

$rs04 = $pdo->query($sql04)->fetchColumn();

$today_num04 = $rs04;

//今日生产

$sql05 = "SELECT count(*) FROM jg_company where `jindushijian` >= unix_timestamp( '$beginTime' ) AND `jindushijian` <= unix_timestamp( '$endTime' ) and jindu=6";

$rs05 = $pdo->query($sql05)->fetchColumn();

$today_num05 = $rs05;

?>

<?php

//本周询盘

$sql01 = "SELECT count(*) FROM jg_company where `jindushijian` >= unix_timestamp( '$beginTime_benzhou' ) AND `jindushijian` <= unix_timestamp( '$endTime_benzhou' ) and jindu=1";

$rs01 = $pdo->query($sql01)->fetchColumn();

$week_num01 = $rs01;

//本周报价

$sql02 = "SELECT count(*) FROM jg_company where `jindushijian` >= unix_timestamp( '$beginTime_benzhou' ) AND `jindushijian` <= unix_timestamp( '$endTime_benzhou' ) and jindu=2";

$rs02 = $pdo->query($sql02)->fetchColumn();

$week_num02 = $rs02;

//本周样品

$sql03 = "SELECT count(*) FROM jg_company where `jindushijian` >= unix_timestamp( '$beginTime_benzhou' ) AND `jindushijian` <= unix_timestamp( '$endTime_benzhou' ) and jindu=3";

$rs03 = $pdo->query($sql03)->fetchColumn();

$week_num03 = $rs03;

//本周定金

$sql04 = "SELECT count(*) FROM jg_company where `jindushijian` >= unix_timestamp( '$beginTime_benzhou' ) AND `jindushijian` <= unix_timestamp( '$endTime_benzhou' ) and jindu=5";

$rs04 = $pdo->query($sql04)->fetchColumn();

$week_num04 = $rs04;

//本周生产

$sql05 = "SELECT count(*) FROM jg_company where `jindushijian` >= unix_timestamp( '$beginTime_benzhou' ) AND `jindushijian` <= unix_timestamp( '$endTime_benzhou' ) and jindu=6";

$rs05 = $pdo->query($sql05)->fetchColumn();

$week_num05 = $rs05;

?>

<?php

//本月询盘

$sql01 = "SELECT count(*) FROM jg_company where `jindushijian` >= unix_timestamp( '$beginTime_benyue' ) AND `jindushijian` <= unix_timestamp( '$endTime_benyue' ) and jindu=1";

$rs01 = $pdo->query($sql01)->fetchColumn();

$month_num01 = $rs01;

//本月报价

$sql02 = "SELECT count(*) FROM jg_company where `jindushijian` >= unix_timestamp( '$beginTime_benyue' ) AND `jindushijian` <= unix_timestamp( '$endTime_benyue' ) and jindu=2";

$rs02 = $pdo->query($sql02)->fetchColumn();

$month_num02 = $rs02;

//本月样品

$sql03 = "SELECT count(*) FROM jg_company where `jindushijian` >= unix_timestamp( '$beginTime_benyue' ) AND `jindushijian` <= unix_timestamp( '$endTime_benyue' ) and jindu=3";

$rs03 = $pdo->query($sql03)->fetchColumn();

$month_num03 = $rs03;

//本月定金

$sql04 = "SELECT count(*) FROM jg_company where `jindushijian` >= unix_timestamp( '$beginTime_benyue' ) AND `jindushijian` <= unix_timestamp( '$endTime_benyue' ) and jindu=5";

$rs04 = $pdo->query($sql04)->fetchColumn();

$month_num04 = $rs04;

//本月生产

$sql05 = "SELECT count(*) FROM jg_company where `jindushijian` >= unix_timestamp( '$beginTime_benyue' ) AND `jindushijian` <= unix_timestamp( '$endTime_benyue' ) and jindu=6";

$rs05 = $pdo->query($sql05)->fetchColumn();

$month_num05 = $rs05;

?>

<?php

//全部询盘

$sql01 = "SELECT count(*) FROM jg_company where jindu=1";

$rs01 = $pdo->query($sql01)->fetchColumn();

$all_num01 = $rs01;

//全部报价

$sql02 = "SELECT count(*) FROM jg_company where jindu=2";

$rs02 = $pdo->query($sql02)->fetchColumn();

$all_num02 = $rs02;

//全部样品

$sql03 = "SELECT count(*) FROM jg_company where jindu=3";

$rs03 = $pdo->query($sql03)->fetchColumn();

$all_num03 = $rs03;

//全部定金

$sql04 = "SELECT count(*) FROM jg_company where jindu=5";

$rs04 = $pdo->query($sql04)->fetchColumn();

$all_num04 = $rs04;

//全部生产

$sql05 = "SELECT count(*) FROM jg_company where jindu=6";

$rs05 = $pdo->query($sql05)->fetchColumn();

$all_num05 = $rs05;

?>

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
java 利用c3p0管理数据库连接池
date picker使用
项目开发过程中,以前每次一遇到这种情况,我都记不住,现在终于记住了
oracle时间类型数据作为条件查询
Statement、PreparedStatement、PreparedStatement + 批处理 的区别
SQL查询拼接存储过程 分页
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服