บทความ > Web Programming

[PHP/SQL] Split date and time for update to database Turn Back

เมื่อ 2018-02-21 16:14:05

1. Get datetime data from some column in database.

SELECT date_format(datetime_column,'%Y-%m-%d') DAT, date_format(datetime_column,'%H:%i:%s') TIM FROM table WHERE Something

2. Put data into each an input (eg. datepicker, timepicker)

3. After editing the Date or Time. And submit form. Let PHP convert it (String) to datetime format before update to database.

$newDate = DateTime::createFromFormat('Y-m-d H:i:s', $_POST['new_date']." ".$_POST['new_time']);
$newDate = $newDate->format('Y-m-d H:i:s');
 
 
Turn Back

Automotive ดูทั้งหมด

IT Update ดูทั้งหมด