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?

1
  • You want to achieve this only by mySQL ? Commented Nov 6, 2018 at 6:49

1 Answer 1

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();
1
  • its not working. Commented Nov 6, 2018 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.