public function flag_spmlds($id)
{
$date = time();
$myJson = "{
'cust_id': 12,
'label_date':".$date."
}";
$this->db->where('id',$id);
$this->db->update('customer', ['label_by' => $myJson, 'label' => 1]);
echo $this->db->last_query();
}
在这里,我必须将时间转换为unixtimestamp,如何做到这一点,有人能帮我吗?
尝试以下操作:
//Create a DateTime object.
$dateTime = new DateTime('2019-04-01');
//Format it into a Unix timestamp.
echo $dateTime->format('U');
并将秒数转换为日期:
echo date('Y/m/d H:i:s', $label_date);
将unix timestamp
转换为人类可读的格式。
$label_date = 1584682935;
$date = new DateTime("@$label_date");
echo $date->format('U = Y-m-d H:i:s');