Now i need to try and get it to send an email 1 hour before by doing a command this should be fun!
you will probably like this way too
// fires every time the date field is called from DB, where NameOfField is the name of the date column in the DB
public function getNameOfFieldAttribute($date)
{
return Carbon\Carbon::parse($date)->format('m/d/Y h:i:s A') ->subHour();
}
@em57 you shouldn't need that. Once you've added the $dates property they will be treated as Carbon instances.
Just can't get it to send 1 hour before now, brain freeze...
You doing a check every minute or so?
You will want to check if the time now is less than or equal to the action date AND action date is greater or equal to the time now -1hour
I can't even work it out right now, it's something like that, greater/less than :P
edited... I tried something like this
$date = '16:30:00';
$timeToCompare = Carbon\Carbon::createFromFormat('H:i:s', $date)->format('H:i:s');
$timeNow = Carbon\Carbon::now()->format('H:i:s');
if($timeToCompare <= $timeNow ){
$diff = $timeToCompare - $timeNow;
echo $timeNow;
echo $timeToCompare;
echo $diff;
//returns an even number
}
So you probably try converting to a unix timestamp
Please sign in or create an account to participate in this conversation.