Is there a way to "return time" in a Laravel project? And set the date to be last month and then all records added to have a timestamp from last month?
Is there a way to "return time" in a Laravel project? And set the date to be last month and then all records added to have a timestamp from last month?
2
Answers
You can use Carbon, laravel has a helper built in
Docs
You can view all available Carbon functions in your project at the following path:
vendor/nesbot/carbon/src/Carbon/Carbon.php
To get last month. More Carbon options
subMonth()
=> if month backstartOfMonth
=> If the start of the current monthsubMonth()->startOfMonth()
=> If start of the last monthTo Update your model, update your
$fillable
, and simple update/create will work