Comments (13)
@jenssegers The whereBetween
query doesn't work with Carbon date, only MongoDate. Using v2.2.4.
$startDate = Carbon::createFromDate(2015, 4, 1);
$endDate = Carbon::createFromDate(2015, 4, 30);
$users = User::whereBetween('created_at', array($startDate, $endDate))->get();
//Return empty result
$startDate = new MongoDate(Carbon::createFromDate(2015, 4, 1)->timestamp);
$endDate = new MongoDate(Carbon::createFromDate(2015, 4, 30)->timestamp);
$users = User::whereBetween('created_at', array($startDate, $endDate))->get();
//Return correct results
Is the Carbon date support not applicable to this case? Thanks!
from laravel-mongodb.
I am facing the issue with new version..²
from laravel-mongodb.
For me, MongoDate()
seems to be working. But new DateTime
would be better I think.
from laravel-mongodb.
I am also having a problem with the dates, I have a script like this:
$from = new MongoDate(Input::get('from')); //from is in time format
$to = new MongoDate(Input::get('to')); // to is in time format
$between = array( $from, $to);
$leads = Lead::whereBetween('created_at', $between)->get();
I don't know what I'm missing but the date range is not working, is there something I am missing? Thanks for writing a great extension btw.
Cheers,
Albert
from laravel-mongodb.
I'm looking into this right now.
from laravel-mongodb.
I did not encounter any problems with dates. Check the date tests in 93e53ec
from laravel-mongodb.
Awesome, got some tips from your tests. Thank you
from laravel-mongodb.
Added some more date tweaks and a bit of documentation: https://github.com/jenssegers/Laravel-MongoDB#dates
from laravel-mongodb.
I added Carbon date support to the latest version. Can anyone report back if he's having problems with these changes?
from laravel-mongodb.
Could you perhaps quickly explain how to get MongoDate objects converted to Carbon instances? Whenever I read out data, the created_at
and updated_at
fields are always of the MongoDate type.
from laravel-mongodb.
I am facing the issue with new version..
from laravel-mongodb.
@sebastiaanluca : u can use MongoDate::toDateTime as given in following link
http://php.net/manual/en/mongodate.todatetime.php
from laravel-mongodb.
@saraht129 @jenssegers I've tired your solution and still get empty result! Also tried (for example)
User::where('created_at','>',$startDate)->where('created_at','<',$endDate)->get();
still get empty result.
I don't know why it doesn't work with more than one where clause 😞
from laravel-mongodb.
Related Issues (20)
- Polymorphic One to One (MorphOne) Relationship [Feature Request] HOT 3
- BelongsToMany detach() doesn't remove id from both collections
- Transaction level not working when use closure
- Unique Rule ignoring fails
- morphOne $model (mysql) -> relation (mongo)
- how it's will work with laravel passport with crearting issue not able to generate personal access token or password HOT 1
- updateOrCreate does not create DB entries HOT 9
- PHPStan errors after 4.3.0 upgrade HOT 1
- How I use laravel passport with this mongodb package ? As I creating Apis for my project so I require passport package. HOT 1
- `createOrFirst` is not triggering `creating` nor `created` model events HOT 8
- [Feature Request] getChanges() not supported HOT 4
- updateOrCreate -> createOrFirst doesn't work as expected HOT 3
- Memory leak when setting nested keys using dot notation HOT 3
- [Feature Request] Use transaction in AWS DocumentDB HOT 1
- whereHas does not work with ObjectId relations HOT 1
- [Feature Request] SANCTUM SUPPORT HOT 3
- Queue retry gets failed : Unable to find failed job with ID []
- Add hasColumn/hasColumns HOT 2
- withCount is not working HOT 6
- Bug : (Exception: Method MongoDB\Laravel\Schema\Grammar::compileColumns does not exist.) HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-mongodb.