Lambneck Posted October 10, 2008 Share Posted October 10, 2008 Hello, I am trying to echo form submission dates like so: date("l M dS, Y, H:i:s") my question is how? I have the following echoing rows from database table. The submission_date is the column where, obviously, the submission dates are kept: <?php //Include database connection details if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); $result = mysql_query("SELECT * FROM $table ORDER BY submission_id DESC"); if (!$result) { die("Query to show fields from table failed:".mysql_error()); } while($row = mysql_fetch_array($result)) { echo "<table id=table1>"; echo "<tr><td><b>"; echo '<a href="resumeDisplay.php?id='.$row['submission_id'].'">'.$row['col_4'].'</a>'; echo "</b><br />"; echo $row['col_2']; echo " | "; echo $row['submission_date']; echo "</font></tr></td>"; echo "</table>"; } mysql_free_result($result); ?> Quote Link to comment https://forums.phpfreaks.com/topic/127818-solved-formated-date/ Share on other sites More sharing options...
Bendude14 Posted October 10, 2008 Share Posted October 10, 2008 what format are they stored as in your db? try looking here see if this helps http://au.php.net/date http://au.php.net/manual/en/function.mktime.php Quote Link to comment https://forums.phpfreaks.com/topic/127818-solved-formated-date/#findComment-661716 Share on other sites More sharing options...
Lambneck Posted October 10, 2008 Author Share Posted October 10, 2008 submission dates are stored as: time() how to echo the submission_date column data formatted as date("l M dS, Y, H:i:s") ? Quote Link to comment https://forums.phpfreaks.com/topic/127818-solved-formated-date/#findComment-661720 Share on other sites More sharing options...
JasonLewis Posted October 10, 2008 Share Posted October 10, 2008 Use the 2nd argument, $timestamp. This allows you to place in a timestamp that you want to format. Check it out on the manual. Quote Link to comment https://forums.phpfreaks.com/topic/127818-solved-formated-date/#findComment-661724 Share on other sites More sharing options...
Lambneck Posted October 10, 2008 Author Share Posted October 10, 2008 sorry, I'm not sure what you mean. as i can tell the function time() stored the time/date of form submissions as an integer in the database column submission_date. I just want that submission date to be echoed as an actual date, because as it is i call the submission_date column to be displayed and it shows up as the 10 digit integer. Quote Link to comment https://forums.phpfreaks.com/topic/127818-solved-formated-date/#findComment-661736 Share on other sites More sharing options...
Bendude14 Posted October 10, 2008 Share Posted October 10, 2008 try this <?php $now = time(); echo 'Now: '. date('d/m/Y', $now) ."\n"; ?> obviously instead replace now with the value out of your database $row['submission_date']; Quote Link to comment https://forums.phpfreaks.com/topic/127818-solved-formated-date/#findComment-661741 Share on other sites More sharing options...
JasonLewis Posted October 10, 2008 Share Posted October 10, 2008 Or with your code: echo date("l M dS, Y, H:i:s", $row['submission_date']); Quote Link to comment https://forums.phpfreaks.com/topic/127818-solved-formated-date/#findComment-661747 Share on other sites More sharing options...
Lambneck Posted October 10, 2008 Author Share Posted October 10, 2008 great i actually tried that before and it didn't work. I must have left something out or left a typo. anyway thanks for the help, much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/127818-solved-formated-date/#findComment-661756 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.