VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: sandomatyas on June 12, 2019, 16:46:02 PM

Title: Problem with dates for multiple prices
Post by: sandomatyas on June 12, 2019, 16:46:02 PM
I already asked about this 4 years back back here I am again :)

I run a site which uses CEST timezone, so we have UTC +2
When I try to set a time-limited price and select today as publish_up and tomorrow as publish_down date for it, VM stores 2019-06-12 00:00:00 and 2019-06-13 00:00:00 in #__virtuemart_product_prices table.
But when you check loadProductPrices method in VirtueMartModelProduct, there is `product_price_publish_down` >= "' .$db->escape($this->_now) . '" where $this->_now is  JFactory::getDate()->toSQL() which is UTC
So this price will be deactivated at 2AM tomorrow because at local midnight will be 10PM in UTC

What do you suggest, which is the correct way to use the real timezone but have the correct price publish up/down times?
Title: Re: Problem with dates for multiple prices
Post by: Milbo on June 20, 2019, 16:23:20 PM
thank you for the bug report.

in the product model, function loadProductPrices use this


if(!isset($this->_now)){

$config = JFactory::getConfig();
$siteOffset = $config->get('offset');
$siteTimezone = new DateTimeZone($siteOffset);

$jnow = JFactory::getDate();
$date = new JDate($jnow);
$date->setTimezone($siteTimezone);
$this->_now = $date->format('Y-m-d H:i:s',true);

//vmdebug('my timezone ',$this->_now);
}


for the if(!isset($this->_now)){