sanderphp Posted May 16, 2008 Share Posted May 16, 2008 I am trying to learn how to combine the year, month, and day that I getting from 3 different fields so I can use that date in my db. Would I combine them before writing them like $date = array($dateyear,$datemonth,$dateday); or $datemonth = $_POST['datemonth']; $dateyear = $_POST['dateyear']; $dateday = $_POST['dateday']; $date = $dateyear.$datemonth.$dateday; I'm sure that concatenation method isn't correct, but I haven't done this before. Or would I better off with something like this? $query = "INSERT INTO info (date) VALUES ('$dateyear $datemonth $dateday')"; Quote Link to comment https://forums.phpfreaks.com/topic/105865-solved-combining-year-month-and-day/ Share on other sites More sharing options...
p2grace Posted May 16, 2008 Share Posted May 16, 2008 What's the field type in the database? Is it date or timestamp? <?php // if date $date = "$dateyear-$datemonth-$dateday"; // if timestamp $date = "$dateyear-$datemonth-$dateday ".date("H:m:s"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/105865-solved-combining-year-month-and-day/#findComment-542564 Share on other sites More sharing options...
sanderphp Posted May 16, 2008 Author Share Posted May 16, 2008 just the date. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/105865-solved-combining-year-month-and-day/#findComment-542568 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.