Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdrago999/284d327693518263331bb6b3534adecc to your computer and use it in GitHub Desktop.
Save jdrago999/284d327693518263331bb6b3534adecc to your computer and use it in GitHub Desktop.
export const datetimeWithTZ = <T extends ColumnBaseConfig>(
column: MySqlDateTimeString<T>
) =>
sql`DATE_FORMAT(${column}, '%Y-%m-%dT%TZ')`.mapWith((v) => new Date(v));
// example
// await db.select({ createdAt: datetimeWithTz(table.createdAt) }).from(table);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment