Form date value different from submitted date

  • Mobilepro
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 89
  • Thank you received: 0

Mobilepro created the topic: Form date value different from submitted date

I use a hidden date field in my forms that loads today's date as the value using
<?php return date("m/d/Y") ?>
. This has always worked but now I'm noticing that it is off by a day ( it shows the next day's date) compared to the submitted date in the database (which has the correct time and date).

Any idea what would cause this?

Thanks
#232666
  • Posts: 2461
  • Karma: 86
  • Thank you received: 333

mihaela replied the topic: Form date value different from submitted date

Hello,

It might be that the server time isn't set properly since this function should return today's date. I assume that is causing the issue.

ALso, you can go through this piece of documentation about the date function and you might find something useful php.net/manual/en/function.date.php .


Regards,

Mihaela
#232673
  • Posts: 80
  • Thank you received: 1

geeksscript replied the topic: Form date value different from submitted date

Hi Mihaela!

I have a hidden field with below value to store date:
<?php return date('Y-m-d h:i:s');?>

In a recent case, one of the user visited the form page & submitted it after 17 hours approx, which caused inaccurate submission date to be stored in database table (via integrator).

Please check below image:


How can I store the submission date & not the one of page load?

Please guide.

Thanks
#236573
Attachments:
  • Posts: 2461
  • Karma: 86
  • Thank you received: 333

mihaela replied the topic: Form date value different from submitted date

Hello,

OK, I understand, since what is put as field's value is filled in on form load, it will return the page's load time instead of the submit time.

Here is you can make it work so that the submit time is saved.

Please go to the Advanced properties of that field for filling in the date.
Then in the Initscript section set Type to Custom and check the "Form Entry" checkbox.

In the code area below put the following code:
function ff_scriptdate_init(element, condition)
{
 setInterval(caltime, 500);


} // ff_scriptdate_init


function caltime() {
var date = new Date();

var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();

ff_getElementByName("scriptdate").value = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
}
NOTE: In order for this to work on your form please replace bothe instances of scriptdate with the Name of that fate field.

Let me know whether this solution works for you.

Regards,

Mihaela
#236590
The following user(s) said Thank You: geeksscript
  • Posts: 80
  • Thank you received: 1

geeksscript replied the topic: Form date value different from submitted date

Hello Mihaela,

Thank you for the solution. Please check below image:


There is a difference of 25 seconds between both the values. Just wanted to check if there is a way to directly save the submitted date into the date column? Because via browser inspect, I noticed the date value is constantly being updated every second. I hope this does not increase memory usage on server.

Please let me know.
#236592
Attachments:
  • Posts: 2461
  • Karma: 86
  • Thank you received: 333

mihaela replied the topic: Form date value different from submitted date

Hello,

Setting this to work exactly as you wanted requires a custom solution and unfortunately, that is out of the scope of our support.

I hope that you will manage to use the solution provided.

Regards,

Mihaela
#236596
The following user(s) said Thank You: geeksscript
Moderators: ForumSupporttomeperica
Time to create page: 0.307 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here