kaiman Posted December 14, 2010 Share Posted December 14, 2010 Okay, I'm back already with another question: Is it possible to use strtotime to display the date like this(?): <?php $get_date = strtotime($_GET['month'],$_GET['day'],$_GET['year']); echo date('F, j, Y', $get_date); ?> Or: <?php $row_date = strtotime($row['month'],$row['day'],$row['year']); echo date('F, j, Y', $row_date); ?> From this script: // get url variables $month = $_GET['month']; $year = $_GET['year']; $day_num = $_GET['day']; // connects to server and selects database. include ("../includes/dbconnect.inc.php"); // table name $table_name = "availability"; // query database for events $result = mysql_query ("SELECT * FROM $table_name WHERE month='$month' AND year='$year' AND day='$day_num' LIMIT 1") or die(mysql_error()); if (mysql_num_rows($result) > 0 ) { while($row = mysql_fetch_array($result)) { extract($row); echo "<h1>Availability for ".$row['month'] . "/" . $row['day'] . "/" . $row['year'] . "</h1>"; echo " <ul>"; echo " <li>Earth Room: " . $row['earth_room'] . "</li>"; echo " <li>Air Room: " . $row['air_room'] . "</li>"; echo " <li>Fire Room: " . $row['fire_room'] . "</li>"; echo " <li>Water Room: " . $row['water_room'] . "</li>"; echo " </ul>"; } } else { echo "<h1>Availability for ".$_GET['month'] . "/" . $_GET['day'] . "/" . $_GET['year'] . "</h1>"; echo " <ul>"; echo " <li>Currently no reservations.</li>"; echo " </ul>"; } I have my date broken down into 3 rows like this: `day` varchar(2) NOT NULL default '', `month` varchar(2) NOT NULL default '', `year` varchar(4) NOT NULL default '', Currently when I run strtotime it gives me this warning and then returns the Epoch date - December, 31, 1969: Warning: strtotime() expects at most 2 parameters, 3 given Is there any way around this or do I need to adjust my DB rows somehow? Any help is appreciated. Thanks again, kaiman Link to comment https://forums.phpfreaks.com/topic/221643-is-this-possible/ Share on other sites More sharing options...
spinsfil Posted December 14, 2010 Share Posted December 14, 2010 Try this <?php $year = $_GET['year']; $month = $_GET['month']; $day = $_GET['day']; $thedate = "$year-$month-$day"; $get_date = strtotime($thedate); echo date('F, j, Y', $get_date); ?> Link to comment https://forums.phpfreaks.com/topic/221643-is-this-possible/#findComment-1147236 Share on other sites More sharing options...
kaiman Posted December 14, 2010 Author Share Posted December 14, 2010 @ spinsfil That worked the charm. Thanks for the help! Cheers, kaiman Link to comment https://forums.phpfreaks.com/topic/221643-is-this-possible/#findComment-1147253 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.