I'm running a Laravel app in a Docker container that is using Ubuntu as its base image. After upgrading from Ubuntu 20.04 to 22.04, SQL Server date type columns started returning with a different format.
Migration:
Schema::create('my_table', function (Blueprint $table) {
$table->bigIncrements('id');
$table->date('due_date');
});
Query:
$dueDate = DB::table('my_table')->find(1)->due_date;
On Ubuntu 20.04, $dueDate
= '2020-01-31', while on 22.04, $dueDate
= 'Jan 31 2020 12:00:00:AM'.
Aside from upgrading Ubuntu, I did not make any other changes.
Dockerfile:
FROM ubuntu:22.04 #Switched from ubuntu:20.04
RUN apt-get update && apt-get install -y software-properties-common
RUN add-apt-repository ppa:ondrej/php
RUN apt-get update && apt-get install -y \
gnupg2 \
nginx \
php8.1 \
php8.1-bcmath \
php8.1-curl \
php8.1-fpm \
php8.1-gd \
php8.1-intl \
php8.1-mbstring \
php8.1-memcached \
php8.1-redis \
php8.1-sybase \
php8.1-xdebug \
php8.1-xml \
php8.1-zip \
&& rm -rf /var/lib/apt/lists/*
COPY . /var/www/html
WORKDIR /var/www/html
CMD tail -f /var/log/nginx/*.log
- PHP version: 8.1.13
- Laravel version: 9.43.0
- SQL Server version: 2017
I am literally stumped. Any help will be very much appreciated! Thank you in advance!