TrederusMaximus
3 years ago
105
9
Laravel

Heart of the Date Format

Posted 3 years ago by TrederusMaximus

Hello all,

I have to work with MS SQL Server which means that I need to change the date format from "Y-m-d H:i:s" to "Y-d-m H:i:s" .

I have found the Model function getDateFormat():

    protected function getDateFormat()
    {
        return $this->dateFormat ?: $this->getConnection()->getQueryGrammar()->getDateFormat();
    }

and then followed it down to "getDateFormat()":

    /**
     * Get the format for database stored dates.
     *
     * @return string
     */
    public function getDateFormat()
    {
        return 'Y-d-m H:i:s';
    }

But if I change the format here that does not seem to have any influence of the date format. I know that there is a way by overriding the getDateFormat() funtion in the model but as I would have to do that for every model and also have other code that I've just required via composer that relies on the underlying date format structure I'd like to change it at it's very heart.

Any ideas and/or experience what would be the best way?

Thanks in advance! :-)

Please sign in or create an account to participate in this conversation.