<?php
error_reporting(0);
if (isset($_POST['customerID'])) {
require 'connect.php';
$customerID = $_POST['customerID'];
$NewTime =  $_POST['NewTime'];
$NewDate =  $_POST['NewDate'];
$Format =  $_POST['Format'];

// DATE MATH 

if($Format == "PM") {
    $explodeTime = explode(":", $NewTime);
    $hourFormat = $explodeTime[0];
    $MinFormat = $explodeTime[1];
    
    // convert to 24Hour FMT
    $ToPMFormat = $hourFormat + 12;
    
    $ModifiedDate = $NewDate." ".$ToPMFormat.":".$MinFormat.":32";
    
}else {
    $ModifiedDate = $NewDate." ".$NewTime.":32";
}

$update = mysqli_query($connect, "UPDATE transactions SET TransDate = '$ModifiedDate' WHERE ID = '$customerID'");
if ($update) {
echo "<p style='text-align: center; color: green;'>SUCCESS</p>";

}else {
echo "<p style='text-align: center; color: green;'>Error: could not complete your request at the moment</p>";
}




}
else {
header("Location: /personal/");
die();
}



















?>