jigen7 Posted October 11, 2007 Share Posted October 11, 2007 suppose $arr7 contains this value '10/5/2007 6:02' how can i format that to be change like this '2007-01-22 08:55:19' when im going to use it in a insert statement here's the code $sql = "INSERT INTO Links(URL,Title,Description,Email,SubmitURL,ContactedOn) VALUES('{$arr[0]}','{$arr[1]}','{$arr[2]}','{$arr[3]}','{$arr[4]}','{$arr[7]}')" original value format = 10/5/2007 6:02 target value format before storing to sql = 2007-01-22 08:55:19 Quote Link to comment https://forums.phpfreaks.com/topic/72718-help-with-php-sql-insert-statement/ Share on other sites More sharing options...
harristweed Posted October 11, 2007 Share Posted October 11, 2007 $new_val=strtotime($arr[7]); $into_db=date("Y-m-d H:i:s",$new_val); //or $into_db=date("Y-d-m H:i:s",$new_val); depending on whether $arr[7] is America(mm/dd/yyyy) or English date format(dd/mm/yyyy) $sql = "INSERT INTO Links(URL,Title,Description,Email,SubmitURL,ContactedOn) VALUES('{$arr[0]}','{$arr[1]}','{$arr[2]}','{$arr[3]}','{$arr[4]}','$into_db" Quote Link to comment https://forums.phpfreaks.com/topic/72718-help-with-php-sql-insert-statement/#findComment-366840 Share on other sites More sharing options...
jigen7 Posted October 11, 2007 Author Share Posted October 11, 2007 wow thx hope it works Quote Link to comment https://forums.phpfreaks.com/topic/72718-help-with-php-sql-insert-statement/#findComment-366843 Share on other sites More sharing options...
Lukela Posted October 11, 2007 Share Posted October 11, 2007 $sql = "INSERT INTO `Links` (`URL`,`Title`,`Description`,`Email`,`SubmitURL`,`ContactedOn`) VALUES('{$arr[0]}','{$arr[1]}','{$arr[2]}','{$arr[3]}','{$arr[4]}','$into_db')" or die(mysql_error()); Well if that doesnt work try this. Quote Link to comment https://forums.phpfreaks.com/topic/72718-help-with-php-sql-insert-statement/#findComment-366862 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.