Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supports PHPs DateTime instances #725

Open
Tigrov opened this issue Jul 9, 2023 · 2 comments
Open

Supports PHPs DateTime instances #725

Tigrov opened this issue Jul 9, 2023 · 2 comments
Assignees
Labels
status:ready for adoption Feel free to implement this issue. type:enhancement Enhancement

Comments

@Tigrov
Copy link
Member

Tigrov commented Jul 9, 2023

Doctrine and Cycle support PHPs DateTime instances

https://www.doctrine-project.org/projects/doctrine-orm/en/2.15/cookbook/working-with-datetime.html

https://cycle-orm.dev/docs/advanced-datetime/current

It would be great if yiisoft/db could support PHPs DateTime instances for types timestamp, datetime, date and time.

$command->insert('datetime_table', ['datetime' => new DateTime()])->execute();
$datetime = (new Query($db))->select(['datetime'])->from('datetime_table')->scalar();
$datetimePhpType = $tableSchema->getColumn('datetime')->phpTypecast($datetime);
$datetimePhpType instanceof DateTimeInterface;

I can realize if you agree.

@samdark samdark added the type:enhancement Enhancement label Jul 10, 2023
@samdark
Copy link
Member

samdark commented Jul 10, 2023

Yes, that is very convenient.

@samdark samdark added the status:ready for adoption Feel free to implement this issue. label Jul 10, 2023
@Tigrov
Copy link
Member Author

Tigrov commented Jul 10, 2023

Good, I implement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready for adoption Feel free to implement this issue. type:enhancement Enhancement
Projects
None yet
Development

No branches or pull requests

2 participants