将jQuery转换为PHP

时间:2018-09-28 12:41:20

标签: php jquery

我想在php中找到一个jquery代码->

我的jQuery:

$other

我的PHP:

var coolDates = [Date.parse(new Date(2018, 10, 15)), Date.parse(new Date(2018, 10, 16))];

我的PHP代码当前返回此值:

public static function getGreetingProduct($id_product)
{
    $sql = Db::getInstance()->executeS('
        SELECT bp.id_block_location_period, bp.is_recurring, bp.date_start, bp.date_end, bp.minimum_retail, bp.rate
        FROM `' . _DB_PREFIX_ . 'block_location` bl
        LEFT JOIN `' . _DB_PREFIX_ . 'block_location_period` bp ON(bl.id_block_location_period = bp.id_block_location_period)
        WHERE bl.id_product = ' . $id_product
    );

    $array = ['greetings' => []];

    foreach ($sql as $period) {

        if (!$period['is_recurring']) {

            $begin = new DateTime($period['date_start']);
            $end = new DateTime($period['date_end']);
            $end = $end->modify('+1 day');

            $period = new DatePeriod(
                $begin,
                new DateInterval('P1D'),
                $end
            );

            foreach ($period as $key => $item) {
                $array['greetings'][] = $item->format('Y ,m ,d');
            }
        }
    }

    return $array;
}

他将不得不提及:

["2018 ,09 ,10", "2018 ,09 ,11", "2018 ,09 ,12", "2018 ,09 ,13", "2018 ,09 ,14", "2018 ,09 ,15", "2018 ,09 ,16", "2018 ,09 ,17", "2018 ,09 ,18", "2018 ,09 ,19", "2018 ,09 ,20", "2018 ,09 ,21", "2018 ,09 ,22", "2018 ,09 ,23", "2018 ,10 ,22", "2018 ,10 ,23", "2018 ,10 ,24", "2018 ,10 ,25", "2018 ,10 ,26", "2018 ,10 ,27", "2018 ,10 ,28"]

据我了解,这是JS [1542236400000, 1542322800000] + 2018, 10, 12中的日期格式。

但是我无法在PHP中做到这一点...

谢谢您的帮助。

0 个答案:

没有答案