Typing DateTimes

interface ICity {
slug: string
name: string
description?: string
createdAt: Date
updatedAt: Date
}
interface ICity {
slug: string
name: string
description?: string
createdAt: Date
updatedAt: Date
}
can I save strings like "2023-09-10 18:16:00" as createdAt and updatedAt ?
5 Replies
Timo Martinson
Timo MartinsonOP2y ago
or what format should a Date have?
ня, привет
Date should have Date class
Timo Martinson
Timo MartinsonOP2y ago
can't I use simple "string"-dates ?
NeTT
NeTT2y ago
nope no but you can use new Date(your_string) to convert them
NeTT
NeTT2y ago