简体   繁体   中英

php MySQL Get Missing day from a Month or BETWEEN days

I need to get an array with days missing from a month.

Get year and month: to Between:

$dateS //have the current given date to make the filter

$year   = mb_substr($dateS, 0, 4);
$month  = mb_substr($dateS, 5, 7);
$tday   = cal_days_in_month(CAL_GREGORIAN, (int)$month, (int)$year); 
$cmonthS    = $year."-".$month."-01 00:00:00";
$cmonthE    = $year."-".$month."-".$tday." 23:59:59";

I am getting the array with this statement:

$stmtpre        =   "SELECT days FROM registry WHERE days BETWEEN '2016-12-01 00:00:00' AND '2016-12-31 00:00:00';";

All data have the current format as date time in MySQL :

XXXX-XX-XX 00:00:00

But it returns the current day, and I need to get in PHP the missing days.

Does anyone know how can i do it?

i create and array with Total days of the month and other array with de Event day i run this function to get the diference into this 2 array:

http://php.net/manual/en/function.array-diff.php

and get finaly my No Event Array

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM