The solution provided by Tobias is for server side custom extension. Which will not work for common cases where your data comes from queries, and you just need to format the value on client side binding.
To use the same library on client side, you can include this JS on your page:
https://www.jsdelivr.com/package/npm/date-fns?tab=files
Next, you need a client side custom formatter, for which you can find reference to here (ignore PHP part in the post, client-side things are same for all server models): Creating Custom Formatters (PHP and client-side)
Then, you can use the function Tobias has shared inside the formatter definition.
Lastly, to use this new formatter, you will have to manually type the binding in the UI to something like:
date_field_from_db.formatToText()
Here, formatToText
will be the name of your client side formatter function.