For example, there is a situation, where I need to output date field in some another format. But this format is not supported by PHP.
For example, I want to output year value in Roman numerals format. Or, I want to calculate year not from the Christmas, but from "the Creation of the world", from foundation of Rome ans so on. Or "the week" in my calendar doesn't contain 7 days, but it contains another quantity of them.
In this case, if I'm not mistaken, I should create new class inheriting it from DateTime class and there redefine method format or do something else.
Can I afterwards notice Drupal to it use my own DateTime class instead default ? That is, for instance, I have created new DateTime field for some node type and I can set my date format for this field in the admin date settings page, in Views and so on.
Is it possible in Drupal 7 ? And is it possible in Drupal 8 ? If yes, how to do it ?