We're Moving to a New Support Platform – Starting June 1st!

We’re excited to let you know that starting June 1st, we’ll be transitioning to a new support system that will be available directly on our product websites – Amelia, wpDataTables, and Report Builder. In fact, the new support platform is already live for Amelia and wpDataTables, and we encourage you to reach out to us there.

You'll always be able to reach us through a widget in the bottom right corner of each website, where you can ask questions, report issues, or simply get assistance.

While we still do not offer live support, a new advanced, AI-powered assistant, trained on our documentation, use cases, and real conversations with our team, is there to help with basic to intermediate questions in no time.

We're doing our best to make this transition smooth and hassle-free. After June 1st, this current support website will redirect you to the new "Contact Us" pages on our product sites.

Thanks for your continued support and trust – we’re excited to bring you an even better support experience!

Okay
  Public Ticket #1316527
Current date placeholder [WORKAROUND]
Closed

Comments

  •  2
    Raul started the conversation

    Hi

    I really need placeholders with current date info. 

    As a suggestion: Please add it :)

    Meanwhile I coded a workaround and I decided to share it. May be someone finds it useful. Better ideas? Better code? Please share :)

    Edit file class.wdttools.php

    After :

            // Shortcode VAR3
            if (strpos($value, '%VAR3%') !== false) {
                $value = str_replace('%VAR3%', $wdtVar3, $value);
            }

    (around line 590)

    Add:

            //Shortcode for date generation. 
            //Use: %CURRENT_DATE%date_format_string% 
            //Example: %CURRENT_DATE%Y-m-d%
            $varname='%CURRENT_DATE%';
            $default_format="Y-m-d"; //in case no format is supplied
            $startpos=0;
            while ($startpos!==false){
                    $startpos=strpos($string, $varname);
                    if ($startpos !== false) {
                            $endpos=strpos($string, '%', $startpos + strlen($varname));
                            if ($endpos!==false){
                                    $placeholder= substr($string,$startpos,$endpos-$startpos+1);
                                    $dateformatstring= substr($string,$startpos + strlen($varname), $endpos - ($startpos + strlen($varname)));
                                    $string = str_replace($placeholder, date($dateformatstring), $string);
                            }else{
                                    $string = str_replace($varname, date($default_format), $string);
                            }
                }
            }
    


    Edit file class.wpdatacolumn.php

    After:

    // Shortcode VAR3
            if (strpos($value, '%VAR3%') !== false) {
                $value = str_replace('%VAR3%', $wdtVar3, $value);
            }

    (around line 590)

    Add:

            //Shortcode for date generation. 
            //Use: %CURRENT_DATE%date_format_string% 
            //Example: %CURRENT_DATE%d/m/Y%
            
            $varname='%CURRENT_DATE%';
            $default_format="d/m/Y"; //in case no format is supplied
            $startpos=0;
            while ($startpos!==false){
                    $startpos=strpos($value, $varname);
                    if ($startpos !== false) {
                            $endpos=strpos($value, '%', $startpos + strlen($varname));
                            if ($endpos!==false){
                                    $placeholder= substr($value,$startpos,$endpos-$startpos+1);
                                    $dateformatstring= substr($value,$startpos + strlen($varname), $endpos - ($startpos + strlen($varname)));
                                    $value = str_replace($placeholder, date($dateformatstring), $value);
                            }else{
                                    $value = str_replace($varname, date($default_format), $value);
                            }
                }
            }
            //This is a workaround for date fields since we cannot write a placeholder in the datetime textbox I use these weird dates as placeholders themselves
                //01/01/1000 - First day of current month
                //15/01/1000 - Current day of current month
                //31/01/1000 - Last day of current month
                $placeholder_first_day_current_month='01/01/1000';
                $placeholder_current_day_current_month='15/01/1000';
                $placeholder_last_day_current_month='31/01/1000';
                if (strpos($value, $placeholder_first_day_current_month) !== false) {
                    $value = str_replace($placeholder_first_day_current_month, date("01/m/Y"), $value);
            }
                if (strpos($value, $placeholder_current_day_current_month) !== false) {
                    $value = str_replace($placeholder_current_day_current_month, date("d/m/Y"), $value);
            }
                if (strpos($value, $placeholder_last_day_current_month) !== false) {
                    $value = str_replace($placeholder_last_day_current_month, date("t/m/Y"), $value);
            }

    I should change also table_settings_block.inc.php so it appears there and lets me set a default value for query, but since I'll probably need to replicate changes on next wpdatatables update, I decided to keep it simple for now.

    Cheers

  •  1,895
    Miloš replied

    Hi Raul,
    Thank you for your purchase.


    Thank you for sharing your solution with us.

    I will definitely add this workaround to our TODO list so we can test it for the future updates.

    Thank you again for sharing your suggestions and ideas with us.


    Best regards.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

    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