Search code examples
angulartypescriptdexie

Angular, Dexie, invalid date


I have a Angular V13.0.2 app that I am expanding. I just recently added Dexie (indexedDB). Now when I try to add a date to my database I only get a "Invalid Date" statement out of it.

// Export clients
export interface Clients {
    id?: number;
    addressId: number;
    firstName: string;
    lastName: string;
    created: Date;
}
// Create a client
const clientId = await db.clients.add({
   addressId: addressId,
   firstName: 'John',
   lastName: 'Doe',
   created: new Date('1995-12-17T03:24:00')
});

The visualization is nothing more then a ngFor over the clients. Am I missing something?

Solution

  • It was not very clear. But Dexie.js uses the UNIX epoch time format. For anyone with the same issue, use:

    new Date('1995-12-17T03:24:00')
    

    I hope someone somewhere might find this useful.