VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: jawadakr on August 11, 2017, 17:31:21 PM

Title: Date field one day behind offset problem
Post by: jawadakr on August 11, 2017, 17:31:21 PM
Hi there

I am using vm 3.2.2 with joomla 3.7.4 on a website with standard linux installation and php 5.5.9-1ubuntu4.22

now the strange problem i am facing is that whenever we enter a date in the date calendar (vm custom field). the joomla is saving it one day behind.

any body else experience something like this before ?

Regards

Jawad
Title: Re: Date field one day behind offset problem
Post by: Milbo on August 11, 2017, 20:07:54 PM
Fixed here http://dev.virtuemart.net/attachments/download/1086/com_virtuemart.3.2.3.9614_extract_first.zip
Title: Re: Date field one day behind offset problem
Post by: jawadakr on August 15, 2017, 22:17:00 PM
Hi Milbo

thanks for the quick reply but I am still facing the same problem with shopper fields on both FE and BE after installing the updated version.

Do I have to set some config options as well ?

Regards

Jawad

Title: Re: Date field one day behind offset problem
Post by: jawadakr on August 28, 2017, 20:58:08 PM
I was able to fix the problem on my own.

It seems that the function broke when we use some other format instead of default one.

I was able to solve this problem by adding this code in vmjsapi.php file in administrator/component/com_virtuemart/helpers directory.

The code below starts at line # 816 for me

if ($date) {
         $formatedDate = JHtml::_('date', $date, $dateFormat );
            // date patch for the one day behind issue.
$date1 = new DateTime($date);
         $formatedDate = $date1->format("$dateFormat");
           
      }
      else {
         $formatedDate = vmText::_('COM_VIRTUEMART_NEVER');
      }
Title: Re: Date field one day behind offset problem
Post by: Milbo on August 30, 2017, 09:25:54 AM
Quote from: jawadakr on August 28, 2017, 20:58:08 PM
The code below starts at line # 816 for me


if ($date) {
$formatedDate = JHtml::_('date', $date, $dateFormat );
            // date patch for the one day behind issue.
$date1 = new DateTime($date);
$formatedDate = $date1->format("$dateFormat");


For what do you need $formatedDate = JHtml::_('date', $date, $dateFormat ); ? I think you can remove this line[/code]
Title: Re: Date field one day behind offset problem
Post by: jawadakr on August 30, 2017, 22:58:21 PM
Oh that is the default code :) I just commented it.