• Hello, you made a very useful and powerful plugin!
    I have a question: I have a date field and I would like the value to be saved in the database like dd/mm/yyyy, but now is displayed the other way around yyyy/mm/dd. Where Can I change it? Thank you so much.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Michael Simpson

    (@msimpson)

    The plugin is storing the date string in the format that the browser sends (which could be different than it displays it). The plugin just displays what it has verbatim.

    You can try to (1) convert it when it goes into the DB or (2) try to convert it when you display it in a shortcode or export.

    (1) You will need to hook in the following PHP code to do the conversion. See: http://cfdbplugin.com/?page_id=747

    
    function convert_date_filter($formData) {
        $formName = 'dateform'; // change this to your form's name
        if ($formData && $formName == $formData->title) {
            // change 'field' to the name of the field holding your date
            $formData->posted_data['field'] =
                    date('d/m/y',
                            strtotime($formData->posted_data['field']));
        }
        return $formData;
    }
    add_filter('cfdb_form_data', 'convert_date_filter');
    

    (2) In a shortcode or export, assuming your date field was called “field”, you can use a transform like this:
    trans="field=strtotime(field)&&field=date(d/m/y,field)"

    Thread Starter marcie73

    (@marcie73)

    It works! Thank you very much! But only for new submissions. Is there a way to change manually old records or I need to operate directly in phpmyadmin? I also need to merge two field columns because I changed the name of a field in the form but it created a new column. I don’t know how to do it. Thank you for any help!

    Plugin Author Michael Simpson

    (@msimpson)

    You can change data by purchasing the CFDB Editor or directly in PHPMyAdmin

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Date field look’ is closed to new replies.