Author Topic: Date field one day behind offset problem  (Read 2615 times)

jawadakr

  • Beginner
  • *
  • Posts: 12
Date field one day behind offset problem
« 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

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10554
  • VM4.0.7 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

jawadakr

  • Beginner
  • *
  • Posts: 12
Re: Date field one day behind offset problem
« Reply #2 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


jawadakr

  • Beginner
  • *
  • Posts: 12
Re: Date field one day behind offset problem
« Reply #3 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');
      }

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10554
  • VM4.0.7 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Date field one day behind offset problem
« Reply #4 on: August 30, 2017, 09:25:54 am »
The code below starts at line # 816 for me

Code: [Select]
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]
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

jawadakr

  • Beginner
  • *
  • Posts: 12
Re: Date field one day behind offset problem
« Reply #5 on: August 30, 2017, 22:58:21 pm »
Oh that is the default code :) I just commented it.