Reputation: 71
Can someone help me with my function, I want my start date to step back one working day but I keep getting Fridays date in the 'start' column of the db if I run the query today, I know its the now() that is doing it can some one point me in the right direction and tell me where to place $start
public function AddNewEvent($title, $start, $end)
{
try {
$db = DB();
$query = $db->prepare("INSERT INTO calendar(title, start, end) VALUES (:title, :start, :end)");
$query->bindParam("title", $title, PDO::PARAM_STR);
$query->bindParam("start",$start=Carbon::now()->subWeekdays(1)->toDateString());
$query->bindParam("end", $end, PDO::PARAM_STR);
$query->execute();
return $db->lastInsertId();
} catch (PDOException $e) {
exit($e->getMessage());
}
}
Upvotes: 3
Views: 1320
Reputation: 71
I have managed to sort it using parse
$this=Carbon::parse($start)->subWeekdays(1)->toDateString();
Upvotes: 2