• Resolved sovitor

    (@sovitor)


    Hi guys,

    Is there a way to automatically show the line insertion date on the frontend?

    Example
    Ninjaforms

    Thanks.

Viewing 1 replies (of 1 total)
  • Plugin Support Syed Numan

    (@annuman)

    Hello @sovitor,

    Yes, it is possible with a custom PHP snippet.

    First, you need to insert the following PHP snippet in the themes’ functions.php file. Then, create a column in the ninja table and keep the Column Key as “created_at”, also, you can take another column with Column Key “updated_at” for setting rows updated date and time.

    add_filter('ninja_tables_item_attributes', function ($attributes) {
        $values = json_decode($attributes['value'], true);
    
        if(isset($values['created_at']) && !$values['created_at']) {
            $values['created_at'] = date('Y-m-d h:i A', current_time('timestamp'));
            $attributes['value'] = json_encode($values, JSON_UNESCAPED_UNICODE);
        }
    
        if(isset($values['updated_at'])) {
            $values['updated_at'] = date('Y-m-d h:i A', current_time('timestamp'));
            $attributes['value'] = json_encode($values, JSON_UNESCAPED_UNICODE);
        }
    
        return $attributes;
    });

    `
    Just keep those columns blank and the date and time will be updated automatically when create a new row or update a row.

    If you have any further queries please submit a support ticket here. https://wpmanageninja.com/support-tickets/ Our support agent will assist you.

    Thanks

Viewing 1 replies (of 1 total)

The topic ‘Frontend Display Data Create Date’ is closed to new replies.