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')"; 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"); ?> 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! 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
Archived
This topic is now archived and is closed to further replies.