0

I am trying to get days difference between 2 dates with mysql query with DATEDIFF function for production_days column:

$collection->getSelect()->joinLeft(array('cvo' => 'cp_vendor_order'), "cvo.parent_order_id = main_table.entity_id AND cvo.vendor_name ='".$configVendorName."'",array('production_days' => new \Zend_Db_Expr('DATEDIFF(ship_by_date,NOW())')))

The issue is NOW() provides different timezone rather than IST(Indian Standard Time) and i want to use IST timezone when we call NOW() , can anyone let me know how to achieve this thing?

0

Try this:

(new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);

OR

(new \DateTime())->format('Y-m-d');

OR

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$objDate = $objectManager->create('Magento\Framework\Stdlib\DateTime\DateTime');
$date = $objDate->gmtDate();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.