Microsoft Sql Server Datetime Column Laravel Carbon Base Model Configuration

15-07-2020

Base Model for Laravel Mssql Datetime Configuration

use Illuminate\Database\Eloquent\Model;

abstract class BaseModel extends Model
{
    protected $dateFormat = 'Y-m-d H:i:s.u';
    public function getDateFormat()
    {
        return 'Y-m-d H:i:s.u';
    }
    
    public function fromDateTime($value)
    {
        return substr(parent::fromDateTime($value), 0, -3);
    }
}

© 2019 All rights reserved. Codesenior.COM