Okay
  Public Ticket #2348410
day in dateformat and timezone
Closed

Comments

  • Pål Viland Monstad started the conversation

    I use the Formidable Forms integration for wpDataTables to pick data for my tables. I use a filed date and time but I am not happy about the result I get.

    1. I need to change the timezone of the time as it is two hours wrong. The reason is probably the time is set in database as CET while Norway is CEO+2

    2. The format of the time and date lacks the possibility to include day. Instead of the fixed list of options I would prefer an input field where all possible variants of the format could be uses. Or at least in addition to the fixed list of options.

  •  2,572
    Aleksandar replied

    Hello Pål Viland Monstad

    Thank you for your purchase.

    The results you're getting are coming from Formidable Forms and your WordPress settings.

    1. wpDataTables doesn't have any way to determine time zones, so it and other plugins depend on what you configured your WordPress to be. If Norway is CET+2, you need to configure that in WP's General settings, but my advice would be to choose your city (or a city near you) instead of an actual time format, as WordPress sometimes has issues with that.

    2. Unfortunately, something like this is not possible. You can choose from existing formats in wpDataTables settings, but please know that even this may not always work, because Formidable Forms are using database format YYYY-MM-DD, and it can return a wrong date. The issue is on Formidable's side as their API (the API that we use to generate tables from Formidable Forms) sends data in that format.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Pål Viland Monstad replied

    Hi, and thanks for you reply. Concerning number 1: It is not possible to reply on the settings in Wordpress or other plugins. The time is stored in database from the Formidable Forms plugin, but format is probably stored as UTC. This means it does not rely on timezones or any settings in Wordpress. It is the plugin that present the time at any time which has to have a setting to make time correct when using the time picked as UTC-format. In this case it is your plugin. I mean there is a need for a setting to correct such time setting. Otherwise the time will in most contries be wrong as the time is stored in UTC format in the database. It is the date stamp which is wrong. I have not tested an input field of type time. Probably is this wrong as well. This means I cannot use your bridge plugin to get the correct answer, which I need.

    Could you please consider making a setting to correct this?

  •  2,572
    Aleksandar replied

    Hi again Pål Viland Monstad

    Like mentioned before - wpDataTables doesn't have any time zone settings, and the data you see in Formidable Form based tables is the data that is being pulled from the database.

    Our plugin can't guess which time zone was used to enter the data, but is simply pulling the data it finds in the database, no more, no less. Formidable Forms store all entries' timestamp in UTC+0 time zone. That's what wpDataTables see, that is what it pulls, and that is what's presented to you. There would have to be a link between Formidable Forms, WordPress General settings, database and wpDataTables to achieve what you're asking. It's not possible to achieve yet.

    From Formidable Forms' documentation:

    Each entry automatically includes a timestamp when it was created. This entry creation date will be saved in UTC time, and displayed in the timezone and format selected on your WordPress Settings → General page.

    This is something Formidable Forms does programmatically - it's nowhere in the database (database being the source of information for creating a wpDataTable), thus wpDataTables can't display it in respect to the time zone you're in.

    Formidable Forms should store the data in the time zone it's currently in, on your website, and in that way this issue would not exist.

    Please feel free to add your suggestion on our Suggest a Feature page, for our developers to take into consideration.

    Don't get me wrong - I'd love it if it were that simple to get it to work like you described, but it's simply not, and I would love to see this "fix" implemented in wpDataTables, but as long as Formidable stores the data in the database in this way, I'm not too confident that it can be achieved without some custom work.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Pål Viland Monstad replied

    Forget about the time zone. If there is a setting to currect the entries from the database it is solved. Can you tell me where in your code the final tables are generated? I can modify this myself if I know where to find the code, I do not use the Excel-layout.

    Now the entries are two hours wrong and I cannot use them to show time.

    And I still do not understand why this is so har to understand. All time entries inn all Wordpress plugins are stored in database in UTC format. Then each and one plugin which make use of those data has to take in mind those data is wrong unless the config in wordpress is used to show it correct.

    But if you can please put me in direction whre to find where in your code this is picked to scrren I can probably fix it myself.

  • Pål Viland Monstad replied

    As far as I can see there are functions in Wordpress to get date and times correct: https://make.wordpress.org/core/2019/09/23/date-time-improvements-wp-5-3/

    Your implementation will never get correct time from any integration as it reads only UTC which is not the correct way of doing things in WP. 

    There is then no need to implement an option to correct the timestamp, as there is already implemented a function to do this. I hope you can reconsider this, as your integration is quite useless when is comes to all kind of form fields of type time.

  • Pål Viland Monstad replied

    I did fix this myself by adding $timestamp = $timestamp + 3600 + 3600; to line 35 of the file wp-content/plugins/wpdatatables/source/class.datetime.wpdatacolumn.php

    This add two hours to the UNC format and then display the correct time on my site.

  • Pål Viland Monstad replied

    And the problem with lack of name of day support:

    $day = date_i18n('l', $timestamp);
    $formattedValue = $day . ' ' . date(get_option('wdtDateFormat') . ' ' . get_option('wdtTimeFormat'), $timestamp);


    Added as following lines to what I posten in previous post.


  •  2,572
    Aleksandar replied

    Hi again Pål Viland Monstad

    I'm glad to see you've managed to work around this issue.

    I will forward it to our development team, so they can include it in the add-on itself, and I'll ask you again to add your suggestion on our Suggest a Feature page, so our developers can see it's a requested feature.

    Thank you for providing the solution.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables