質問

I have a datepicker that returns

$Time: 09:00 (this is string)

$Date: 2014-05-01 (this is string)

I want to combine them as strings to get this:

$From: 2014-05-02T09:00:00

So i need $From = $Date + 'T' + $Time + ':00'

Why isn't this working:

include 'Db.php';

$dateFrom = '2014-05-02' . 'T' . '09:00' . ':00';
$dateTo = '2014-05-02' . 'T' . '14:00' . ':00';

$con = DbConnect();

$sql = "insert into calendar(ContactName, DateFrom, DateTo, ContactPhone) values ('User', '".$dateFrom."', '".$dateTo."', '1234567' )";

print(json_encode(mysqli_affected_rows($con))); 

mysqli_close($con);  
役に立ちましたか?

解決

it's very simple
you just have to use "." insted of "+"

$From = $Date . 'T' . $Time . ':00'

Edit:

include 'Db.php';

$dateFrom = '2014-05-02' . 'T' . '09:00' . ':00';
$dateTo = '2014-05-02' . 'T' . '14:00' . ':00';

$con = DbConnect();

$sql = "insert into calendar(ContactName, DateFrom, DateTo, ContactPhone) values ('User', '".$dateFrom."', '".$dateTo."', '1234567' )";
if(mysqli_query($con,$sql)){

    print(json_encode(mysqli_affected_rows($con))); 

    mysqli_close($con); 
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top