# How to use timestamps without timezones in Vapor 4.x?

**URL:** <https://forums.swift.org/t/how-to-use-timestamps-without-timezones-in-vapor-4-x/52574>\
**Category:** Vapor\
**Tags:** vapor-4\
**Created:** [October 4, 2021, 5:28am UTC](https://forums.swift.org/t/how-to-use-timestamps-without-timezones-in-vapor-4-x/52574 "2021-10-04T05:28:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonyarnold](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tonyarnold/32/30924_2.png) [@tonyarnold](https://forums.swift.org/u/tonyarnold)\
**Post date:** [October 4, 2021, 5:28am UTC](https://forums.swift.org/t/how-to-use-timestamps-without-timezones-in-vapor-4-x/52574/1 "2021-10-04T05:28:27Z")

</div>

I have an existing Vapor 3 application in production that has a fair bit of data stored in a PostgreSQL database. I'm currently in the process of upgrading from Vapor 3 to Vapor 4, and I note that the default `.datetime` type in Vapor 4 migrations is creating columns with a type of `timestamp with time zone NOT NULL`.

Vapor 3 used `timestamp without time zone`.

I'd really prefer not to have to migrate all of the CRUD timestamps to a new format if it's not necessary to. Is there a way to specify the format of my `.datetime` data in the migration/model?

---

<div class="post-metadata">

**Author:** ![gwynne](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/gwynne/32/24337_2.png) [@gwynne](https://forums.swift.org/u/gwynne)\
**Post date:** [October 4, 2021, 7:55pm UTC](https://forums.swift.org/t/how-to-use-timestamps-without-timezones-in-vapor-4-x/52574/2 "2021-10-04T19:55:36Z")

</div>

In your Vapor 4 migration, use `.custom(SQLRaw("TIMESTAMP WITHOUT TIME ZONE"))` instead of `.datetime`. There is unfortunately no simpler way that I recall.

---

<div class="post-metadata">

**Author:** ![tonyarnold](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tonyarnold/32/30924_2.png) [@tonyarnold](https://forums.swift.org/u/tonyarnold)\
**Post date:** [October 4, 2021, 8:49pm UTC](https://forums.swift.org/t/how-to-use-timestamps-without-timezones-in-vapor-4-x/52574/3 "2021-10-04T20:49:21Z")

</div>

Thanks, Gwynne. That’s a reasonably contained workaround - do I need to do anything from the model side, or will it respect the format of the column?

---

<div class="post-metadata">

**Author:** ![gwynne](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/gwynne/32/24337_2.png) [@gwynne](https://forums.swift.org/u/gwynne)\
**Post date:** [October 4, 2021, 11:47pm UTC](https://forums.swift.org/t/how-to-use-timestamps-without-timezones-in-vapor-4-x/52574/4 "2021-10-04T23:47:01Z")

</div>

To be perfectly honest, I'm not 100% sure. It should "just work", but please let me know if your experience is otherwise!

---

<div class="post-metadata">

**Author:** ![tonyarnold](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tonyarnold/32/30924_2.png) [@tonyarnold](https://forums.swift.org/u/tonyarnold)\
**Post date:** [October 5, 2021, 12:25am UTC](https://forums.swift.org/t/how-to-use-timestamps-without-timezones-in-vapor-4-x/52574/5 "2021-10-05T00:25:50Z")

</div>

I've just tried using the custom data type, and Fluent (or PostgreSQL) is decoding the dates incorrectly. I assume it's treating them as if they include the timezone.

---

<div class="post-metadata">

**Author:** ![tonyarnold](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tonyarnold/32/30924_2.png) [@tonyarnold](https://forums.swift.org/u/tonyarnold)\
**Post date:** [October 5, 2021, 12:56am UTC](https://forums.swift.org/t/how-to-use-timestamps-without-timezones-in-vapor-4-x/52574/6 "2021-10-05T00:56:34Z")

</div>

I think I'm just going to need to manually migrate the column in my existing schema to use a timezone. That's okay, it appears to be less onerous than I had assumed.

Thanks for the info and the advice, Gwynne!
