How Can I convert number in controller to hours and minutes then to get requested variable to compare if its in the range between to times, Im storing in the database just number of hour like: 22 which means 22:00:00 2 which means 02:00:00 and so on hope you have a solution
You can use the amazing Carbon for this:
// import at the top of your class
use Carbon\Carbon;
Carbon::createFromFormat('H', 22)->format('H:i:s');
// => "22:00:00"
To use it for comparison, just use the first part without the format, but then when you create the date like this it will use the current date, I don't know what you want to compare? Is it just the hours or the date as well?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With