# Set the default value of a date column in Phinx migrations

**URL:** <https://discourse.cakephp.org/t/set-the-default-value-of-a-date-column-in-phinx-migrations/12959>\
**Category:** Uncategorized\
**Created:** [September 9, 2026, 10:00am UTC](https://discourse.cakephp.org/t/set-the-default-value-of-a-date-column-in-phinx-migrations/12959 "2026-09-09T10:00:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![deanoj](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@deanoj](https://discourse.cakephp.org/u/deanoj)\
**Post date:** [September 9, 2026, 10:00am UTC](https://discourse.cakephp.org/t/set-the-default-value-of-a-date-column-in-phinx-migrations/12959/1 "2026-09-09T10:00:57Z")

</div>

Hello,

I want to set the default of a date column to todays date using Phinx migrations.

I can use CURRENT\_TIMESTAMP for datetime columns, but it doesn’t work for date columns. I have also tried CURRENT\_DATE without success.

I’ve gone thru the documentation and cannot find an answer.

Is this possible using Phinx? I am using a MySQL database in my application.

Thanks, Dean.

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [September 9, 2026, 10:47am UTC](https://discourse.cakephp.org/t/set-the-default-value-of-a-date-column-in-phinx-migrations/12959/2 "2026-09-09T10:47:10Z")

</div>

Have you tried this?

```php
'default' => \Phinx\Util\Literal::from('CURRENT_DATE()')

```

> **[\\Phinx\\Util\\Literal::from - Writing Migrations - 0.16](https://book.cakephp.org/phinx/0/en/migrations.html#custom-column-types-default-values)**
>
> Column types are specified as strings and can be one of:

---

<div class="post-metadata">

**Author:** ![deanoj](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@deanoj](https://discourse.cakephp.org/u/deanoj)\
**Post date:** [September 9, 2026, 11:24am UTC](https://discourse.cakephp.org/t/set-the-default-value-of-a-date-column-in-phinx-migrations/12959/3 "2026-09-09T11:24:14Z")

</div>

Yes, and it just throws an error when trying to create the table. I have tried a few different variations, but the generated SQL always adds in quotes around the (CURRENT\_DATE) part that I need in the SQL.

Generated:

`start_date DATE NOT NULL DEFAULT '(CURRENT_DATE)'`

What I need:

`start_date DATE NOT NULL DEFAULT (CURRENT_DATE)`

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [September 9, 2026, 11:46am UTC](https://discourse.cakephp.org/t/set-the-default-value-of-a-date-column-in-phinx-migrations/12959/4 "2026-09-09T11:46:58Z")

</div>

```php
->addColumn('mydate', 'date', [
    'default' => \Phinx\Util\Literal::from('CURRENT_DATE')
])

```

make sure to NOT have the `()` at the end of `CURRENT_DATE`

---

<div class="post-metadata">

**Author:** ![deanoj](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@deanoj](https://discourse.cakephp.org/u/deanoj)\
**Post date:** [September 9, 2026, 12:14pm UTC](https://discourse.cakephp.org/t/set-the-default-value-of-a-date-column-in-phinx-migrations/12959/5 "2026-09-09T12:14:56Z")

</div>

Yep, tried this as well. Result:

```auto
`start_date` DATE NOT NULL DEFAULT 'CURRENT_DATE',

```

Also tried this:

```auto
'default' => \Phinx\Util\Literal::from('(CURRENT_DATE)')

```

result:  
`start_date DATE NOT NULL DEFAULT '(CURRENT_DATE)'`

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [September 9, 2026, 12:37pm UTC](https://discourse.cakephp.org/t/set-the-default-value-of-a-date-column-in-phinx-migrations/12959/6 "2026-09-09T12:37:33Z")

</div>

the code i posted above worked for me on cakephp 4.6.5 with phinx 0.13.4

---

<div class="post-metadata">

**Author:** ![jmcd73](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/jmcd73/32/481_2.png) [@jmcd73](https://discourse.cakephp.org/u/jmcd73)\
**Post date:** [September 16, 2026, 6:33am UTC](https://discourse.cakephp.org/t/set-the-default-value-of-a-date-column-in-phinx-migrations/12959/8 "2026-09-16T06:33:00Z")

</div>

I couldn’t get Literal to work on Cake 5.4.2

But using `execute($sql)` as a work-a-round allowed it to work.

```auto
public function change(): void
    {
        $table = $this->table('table_name');
        $table->addColumn('my_date', 'date', [
            'null' => false,
        ]);
        $table->create();

        $this->execute('ALTER TABLE table_name ALTER COLUMN my_date SET DEFAULT (CURRENT_DATE);');
    }

```

I am using 11.8.6-MariaDB-5ubuntu0.1 from Ubuntu

---

<div class="post-metadata">

**Author:** ![jmcd73](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/jmcd73/32/481_2.png) [@jmcd73](https://discourse.cakephp.org/u/jmcd73)\
**Post date:** [September 18, 2026, 9:51am UTC](https://discourse.cakephp.org/t/set-the-default-value-of-a-date-column-in-phinx-migrations/12959/9 "2026-09-18T09:51:52Z")

</div>

I found the issue. Use `\Migrations\Db\Literal`

```auto
->addColumn('mydate', 'date', [
    'default' => \Migrations\Db\Literal::from('(CURRENT_DATE)')
])

```
