Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Gabotronix's avatar

Laravel : check models were created_at is after javascript Date timestamp

in my react native app, when app goes to background I store a timestamp on my data store, then when my app goes to foreground I fire a post call with the stored timestamp in order to check if any of Model where created after timestamp.

How can I use laravel query builder to do that?

Should I use Carbon to format the javascript datetime first?

let lastTimeScreenFocused = new Date();

//then after some time I do the backend request and want to check if any new Model was created after lastTimeScreenFocused 

$modelsCreatedAfterLastTimeFocused = false;

$modelsCreatedAfterLastTimeFocused = Model::where('created_at')->first();

0 likes
1 reply
Snapey's avatar
if($modelsCreatedAfterLastTimeFocused = Model::where('created_at','>',$lastTime)->exists()) {

// there are some new records

}

Please or to participate in this conversation.