hiron0424
4/23/2020 - 8:42 AM

dateTime関数

<?php
    $base_start_date = new DateTime($date);
    $base_end_date = new DateTime($date);
    $target_start_date = $base_start_date->sub(new DateInterval('P10D'))->format('Y-m-d h:i:s'); // 1日マイナス
    $target_end_date = $base_end_date->add(new DateInterval('P10D'))->format('Y-m-d h:i:s'); // 1日追加
<?php
 if ($order_status === 0 ) {
            $purchase_date = new Datetime($order_info[0]['created_at']);
            $expiration_date = $purchase_date->add(new DateInterval('P180D'))->format('M.d.Y');
        } elseif ($order_status === 1 || $order_status === 2) {
            $period = ProductsTable::selectProductPeriod($product_id);
            $usage_start_date = new Datetime($order_info[0]['start_date']);
            $expiration_date = $usage_start_date->add(new DateInterval('P'.$period.'D'))->format('M.d.Y');
        }