Formatting a date column in table builder

william - 6 days ago

In my tablebuilder, i have a custom query for my view ( see below ). I would like to format that date to only display year and month. What is the best way?

protected $views = [
    'future' => [
        'query'   => FutureQuery::class,
        'text'    => 'Future Events',
        'columns' => [
            'title',
            'date'

        ],
    ],
    'past' => [
        'query'   => PastQuery::class,
        'text'    => 'Past Events',
        'columns' => [
            'title',
            'date'

        ],
    ],
    'all'
];

Answer

- 6 days ago

Answer

protected $views = [
    'future' => [
        'query'   => FutureQuery::class,
        'text'    => 'Future Events',
        'columns' => [
            'title',
            'date' => [
                'value' => "entry.date.format('M Y')",
            ],

        ],
    ],
    'past'   => [
        'query'   => PastQuery::class,
        'text'    => 'Past Events',
        'columns' => [
            'title',
            'date' => [
                'value' => "entry.date.format('M Y')",
            ],

        ],
    ],
    'all',
];

william - 6 days ago

Answer

protected $views = [
    'future' => [
        'query'   => FutureQuery::class,
        'text'    => 'Future Events',
        'columns' => [
            'title',
            'date' => [
                'value' => "entry.date.format('M Y')",
            ],

        ],
    ],
    'past'   => [
        'query'   => PastQuery::class,
        'text'    => 'Past Events',
        'columns' => [
            'title',
            'date' => [
                'value' => "entry.date.format('M Y')",
            ],

        ],
    ],
    'all',
];