Skip to content

Instantly share code, notes, and snippets.

@bran921007
Created March 29, 2022 12:12
Show Gist options
  • Save bran921007/0b0a1d2518a3d06874dfc0083983c5a5 to your computer and use it in GitHub Desktop.
Save bran921007/0b0a1d2518a3d06874dfc0083983c5a5 to your computer and use it in GitHub Desktop.
retrieve records between two timestamps in Laravel
Post::whereBetween('published_at',[
$request->from ?? '1970-01-01',
$request->to ?? today()->toDateTimeString(),
])->get();
//source: https://twitter.com/ecrmnn/status/1508472237833297927
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment