dadamssg Posted January 31, 2009 Share Posted January 31, 2009 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 More sharing options...
revraz Posted January 31, 2009 Share Posted January 31, 2009 By having session_start under your HTML tags, you would always get errors. Link to comment https://forums.phpfreaks.com/topic/143273-wrong-date-time/#findComment-751374 Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 thanks, i just fixed that. works now but what about those stupid dates? Warning: date_format() expects parameter 1 to be DateTime, string given on line 25 all the dates in the database are in the datetime format Link to comment https://forums.phpfreaks.com/topic/143273-wrong-date-time/#findComment-751375 Share on other sites More sharing options...
PFMaBiSmAd Posted January 31, 2009 Share Posted January 31, 2009 The php date_format() function expects - Parameters object Procedural style only: A DateTime object returned by date_create() Link to comment https://forums.phpfreaks.com/topic/143273-wrong-date-time/#findComment-751381 Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 how should i go about formatting and displaying the dates if date_format() isn't working? i don't get it...it was working exactly as-is a while ago Link to comment https://forums.phpfreaks.com/topic/143273-wrong-date-time/#findComment-751386 Share on other sites More sharing options...
printf Posted January 31, 2009 Share Posted January 31, 2009 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 More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 how do i make the query do that? Link to comment https://forums.phpfreaks.com/topic/143273-wrong-date-time/#findComment-751389 Share on other sites More sharing options...
printf Posted January 31, 2009 Share Posted January 31, 2009 just like I wrote above.. Link to comment https://forums.phpfreaks.com/topic/143273-wrong-date-time/#findComment-751392 Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 ...you didn't write anything above...all i see is a horizontal scroll bar in your post Link to comment https://forums.phpfreaks.com/topic/143273-wrong-date-time/#findComment-751393 Share on other sites More sharing options...
printf Posted January 31, 2009 Share Posted January 31, 2009 I see it, let me add some line breaks and see it it shows up... Link to comment https://forums.phpfreaks.com/topic/143273-wrong-date-time/#findComment-751395 Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 wow that worked perfectly, thank you! Link to comment https://forums.phpfreaks.com/topic/143273-wrong-date-time/#findComment-751409 Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 whats the symbol i need to put to display the AM PM to am pm for the sql query? Link to comment https://forums.phpfreaks.com/topic/143273-wrong-date-time/#findComment-751420 Share on other sites More sharing options...
printf Posted January 31, 2009 Share Posted January 31, 2009 It should be... %p Here is a guide of all the specifier characters, bookmark it... MySQL Date Format Link to comment https://forums.phpfreaks.com/topic/143273-wrong-date-time/#findComment-751421 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.