Jump to content

wrong date time?


dadamssg

Recommended Posts

so wierd, i tried changing curdate() to curdatetime() but i guess that doesn't exist so i changed it back and no im getting errors when im formatting the $startt and $endt variables, but they were working fine before. any suggestions? oh and im getting an error with the session start() too, which i didn't get before

 

<?php
/* program: showevents.php*/

?>

<html>
<body>
<?php
   session_start();
   include("caneck.inc");
   
   $cxn = mysqli_connect($host,$user,$passwd,$dbname)
          or die ("Couldn't connect");
    
/*select todays events*/

$quer = "SELECT * FROM test WHERE DATE(start) <= CURDATE() AND DATE(end) >= CURDATE() ORDER BY start DESC";			
$result = mysqli_query($cxn,$quer)
          or die ("Couldn't execute");
		  
while($row = mysqli_fetch_assoc($result))
   {    
    /*Format dates to display*/

     $startt = DATE_FORMAT($row['start'], '%b %e %Y %l %i %p');
 $endt = DATE_FORMAT($row['end'], '%b %e %Y %l %i %p');

echo " <table border='3'>";
echo " <tr>"; 
echo "<td>{$row['eventid']}</td>";
echo "<td>{$row['created']}</td>";
echo "<td>{$row['title']}</td>";
echo "<td>{$row['event']}</td>";
echo "<td>{$row['description']}</td>";
echo "<td>{$row['location']}</td>";
echo "<td>/$$startt</td>";
echo "<td>/$$endt</td>";
echo "</tr></table>";
   }
?>
</body></html>

Link to comment
https://forums.phpfreaks.com/topic/143273-wrong-date-time/
Share on other sites

change your query, let the database do it...

 

//
//
//
//

$quer = "SELECT eventid, created, title, event, description, location, DATE_FORMAT(start, '%b %e %Y %l %i %p') AS start, DATE_FORMAT(end, '%b %e %Y %l %i %p') AS end FROM test WHERE DATE(start) <= CURDATE() AND DATE(end) >= CURDATE() ORDER BY start DESC";

//
//
//
//

Link to comment
https://forums.phpfreaks.com/topic/143273-wrong-date-time/#findComment-751388
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.