Adding dates from SQL in PHP (types Datetime + Time) -
i'd add together 2 values mysql database in php app. 1 stored datetime type, other 1 time.
$datetime; // "2013-02-08 14:00:00" $time; // "01:00:00"
i'd add together 1 hr $datetime, doesn't give me right result:
$newdatetime = strtotime($datetime) + strtotime($time); echo date('y-m-d h:i:s', $newdatetime); // "1920-02-11 08:31:44"
how can correctly?
$dt = new datetime("2013-02-08 14:00:00"); $dt->modify('+1 hour'); echo $dt->format('y-m-d h:i:s');
see in action
php sql date datetime
No comments:
Post a Comment