How to change the date and time in REST API for comments?
/**
* Add a Formatted Date to the WordPress REST API JSON Post Object
*
*/
add_action('rest_api_init', function() {
register_rest_field(
array('comment'),
'formatted_date',
array(
'get_callback' = function() {
return get_the_date();
},
'update_callback' = null,
'schema' = null,
)
);
});
This is not working for me. I am constantly getting the following in my JSON:
formatted_date:false,
How can I show it in a format like: 28 November 2021, 15:00
?