Reputation: 1354
I have a function which adds an item to the basket. In this function, it checks to see if a basket already exists for this user and creates or updates the basket accordingly. When creating or updating the basket, I need a timeout field set to 4 hours in the future. However, when I create or update a basket, the dateTime field for the timeout is at 0000-00-00 00:00:00. Here is my code (php using the codeigniter framework):
$dateTime = date("Y-d-m h:m:s", strtotime("+4 hours"));
if($query->num_rows() != 1)
{
$this->db->insert("baskets", array("basket_session" => session_id(), "basket_timeout" => $dateTime, "basket_delivery" => "0.00"));
}
else
{
$this->db->where("basket_session", session_id());
$this->db->update("baskets", array("basket_timeout" => $dateTime));
}
What am I missing?
Upvotes: 1
Views: 7262
Reputation: 2288
Change
$dateTime = date("Y-d-m h:m:s", strtotime("+4 hours"));
to
$dateTime = date("Y-m-d H:i:s", strtotime("+4 hours"));
Upvotes: 1
Reputation: 100175
TRy:
$dateTime = date("Y-m-d H:i:s", strtotime("+4 hours"));
Upvotes: 1