mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
14 lines
417 B
TypeScript
14 lines
417 B
TypeScript
import { ValueTransformer } from 'typeorm';
|
|
|
|
export class DateTimeTransformer implements ValueTransformer {
|
|
to(value: Date): any {
|
|
// Convert the local time to UTC before saving to the database
|
|
const utcTime = value?.toLocaleString();
|
|
return utcTime;
|
|
}
|
|
|
|
from(value: any): Date {
|
|
// Convert the UTC time from the database to the local time zone
|
|
return value;
|
|
}
|
|
} |