Date column returns a date string instead of a date object
See original GitHub issueIssue type:
[ ] question [x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[x] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
TypeORM version:
[ ] latest
[ ] @next
[x] 0.2.6
(or put your version here)
If I set a date column with @CreateDateColumn({type:'Date'})
in an entity. The result contains a date string {created: "2018-05-18"}
instead of a date object.
I think it’s a bug because a date time column @CreateDateColumn()
would return a date object.
@Entity()
export class Rate {
@PrimaryGeneratedColumn()
readonly id: number;
@CreateDateColumn({type:'date'})
created: Date;
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:31 (5 by maintainers)
Top Results From Across the Web
Parsing a string to a date in JavaScript - Stack Overflow
Just concatenate your date string (using ISO format) with "T00:00:00" in the end and use the JavaScript Date() constructor, like the example below....
Read more >Demystifying DateTime Manipulation in JavaScript - Toptal
Try to avoid creating a date from a string unless it is in ISO date format. Use the Date(year, month, date, hours, minutes,...
Read more >datetime — Basic date and time types — Python 3.11.1 ...
Returns a string representation of the timedelta object as a constructor call with canonical attribute values. Notes: This is exact but may overflow....
Read more >Convert a String to a Date object in TypeScript | bobbyhadz
Use the Date() constructor to convert a string to a Date object in TypeScript, e.g. const date = new Date('2024-07-21') . The Date()...
Read more >Date - JavaScript - MDN Web Docs - Mozilla
Chrome Edge
Date Full support. Chrome1. Toggle history Full support. Edge12. Toggle hist...
@@toPrimitive Full support. Chrome47. Toggle history Full support. Edge15. Toggle hist...
Date() constructor...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
Top GitHub Comments
This violates TypeScript type checking !
Let’s say we have a
FooEntity
and aFooService
like this :The type of
date
is checked againstDate
at compile type and is insteadstring
at runtime.Hi @qbodart, I don’t believe you 😃