ManInBlack Posted September 2, 2009 Share Posted September 2, 2009 Hi. I'm try put select datetime into mysql dbtable ... put it came everytime '1969-12-31 17:00:00' // artal = year // manudur = month // dagur = day // klst = hour // minutur = minutes // sekundur = Sek // $timar="$artal-$manudur-$dagur $klst:$minutur:$sekundur"; $timasetning = date('Y-m-d H:i:s', strtotime($timar)) ; if( $_GET['adgerd'] == 'senda' ) { $flokkur = $_POST['flokkur']; $tengill = $_POST['tengill']; $lysing = $_POST['lysing']; $dagur = $_POST['dagur']; $manudaur = $_POST['manudur']; $klst = $_POST['klst']; $minutur = $_POST['minutur']; $sekundur = '00'; $artal = '2009'; $sent_af = ''; $timar="$artal-$manudur-$dagur $klst:$minutur:$sekundur"; $timasetning = date('Y-m-d H:i:s', strtotime($timar)) ; $sql="INSERT INTO tenglar (flokkur,url,texti,dagstimi) VALUES ('$flokkur','$tengill','$lysing','$timasetning')"; if (!mysql_db_query('hittis_tenglasafn',$sql,$tengja))die('villa kom upp: ' . mysql_error()); { echo 'Ég er ánægður með þig Tókst að bæta við tengli!'; } } Link to comment https://forums.phpfreaks.com/topic/172833-dropdown-select-insert-date-into-database/ Share on other sites More sharing options...
ManInBlack Posted September 2, 2009 Author Share Posted September 2, 2009 What are the wrong thing I'm doing in this code? I have been searching on google, I'm really not find the problem anohter code : ( Link to comment https://forums.phpfreaks.com/topic/172833-dropdown-select-insert-date-into-database/#findComment-911063 Share on other sites More sharing options...
DEVILofDARKNESS Posted September 2, 2009 Share Posted September 2, 2009 Ofcourse it comes in that way, you ask for it: date('Y-m-d H:i:s') this outputs the date in Year-Month-Day Hour-Minute-Second Link to comment https://forums.phpfreaks.com/topic/172833-dropdown-select-insert-date-into-database/#findComment-911104 Share on other sites More sharing options...
PFMaBiSmAd Posted September 2, 2009 Share Posted September 2, 2009 The form is the source for the values, are you sure the $_POST variables contain what you expect? Link to comment https://forums.phpfreaks.com/topic/172833-dropdown-select-insert-date-into-database/#findComment-911127 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.