arn_php Posted August 23, 2008 Share Posted August 23, 2008 I have a table within the mysql that has a date entry. I would like to show it on the webpage using this code: '.stripslashes($row['tgl']).' tgl here is the date data. The date data is actually : 08-11-2008 but then into my web page, it shows: 1218430800. What is wrong with my code? Thanks. Link to comment https://forums.phpfreaks.com/topic/120954-solved-showing-date-from-mysql/ Share on other sites More sharing options...
marcus Posted August 23, 2008 Share Posted August 23, 2008 echo date("m d, Y",$time); Link to comment https://forums.phpfreaks.com/topic/120954-solved-showing-date-from-mysql/#findComment-623550 Share on other sites More sharing options...
arn_php Posted August 23, 2008 Author Share Posted August 23, 2008 Thanks man, but isn't echo date("m d, Y",$time); would show the date today? I need to show the date from my mysql database, or do you mean echo date("m d, Y",$tgl); Link to comment https://forums.phpfreaks.com/topic/120954-solved-showing-date-from-mysql/#findComment-623552 Share on other sites More sharing options...
marcus Posted August 23, 2008 Share Posted August 23, 2008 Well obviously my $time variable was in reference to yours, so yes. Link to comment https://forums.phpfreaks.com/topic/120954-solved-showing-date-from-mysql/#findComment-623554 Share on other sites More sharing options...
arn_php Posted August 23, 2008 Author Share Posted August 23, 2008 Sorry man, I put echo 'Date: '.date("M d, Y",$tgl).' ';, then this is the date I got : Date : Dec 31, 1969 which is far away from my actual data date which is Aug 11, 08 (the Mysql shows it as 1218430800). Link to comment https://forums.phpfreaks.com/topic/120954-solved-showing-date-from-mysql/#findComment-623560 Share on other sites More sharing options...
marcus Posted August 23, 2008 Share Posted August 23, 2008 <?php echo date("m d y",1218430800); ?> I get 08 11 08 Link to comment https://forums.phpfreaks.com/topic/120954-solved-showing-date-from-mysql/#findComment-623566 Share on other sites More sharing options...
arn_php Posted August 23, 2008 Author Share Posted August 23, 2008 You are right! uh.. what's wrong with me? here is the whole code: <?php $query="SELECT * FROM arnold_next_meeting WHERE flag_status ='1'"; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { echo '<ul> <li>Date : <b>'.date("M d, Y",$tgl).'</b></li> <li>Place : <b>'.stripslashes($row['place']).'</b></li> } ?> Why does it shows the Date : Dec 31, 1969 ? Am I putting this wrong? Link to comment https://forums.phpfreaks.com/topic/120954-solved-showing-date-from-mysql/#findComment-623570 Share on other sites More sharing options...
marcus Posted August 23, 2008 Share Posted August 23, 2008 $tgl is never defined. Link to comment https://forums.phpfreaks.com/topic/120954-solved-showing-date-from-mysql/#findComment-623571 Share on other sites More sharing options...
arn_php Posted August 23, 2008 Author Share Posted August 23, 2008 Please be more specific as it is all confusing to me. Thanks Link to comment https://forums.phpfreaks.com/topic/120954-solved-showing-date-from-mysql/#findComment-623574 Share on other sites More sharing options...
JasonLewis Posted August 23, 2008 Share Posted August 23, 2008 <?php $query="SELECT * FROM arnold_next_meeting WHERE flag_status ='1'"; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { echo '<ul> <li>Date : '.date("M d, Y",$row['tgl']).'</li> <li>Place : '.stripslashes($row['place']).'</li> } ?> You haven't set $tgl, so I assumed it was a row in your database. Link to comment https://forums.phpfreaks.com/topic/120954-solved-showing-date-from-mysql/#findComment-623576 Share on other sites More sharing options...
arn_php Posted August 23, 2008 Author Share Posted August 23, 2008 Wow! that's it!! Link to comment https://forums.phpfreaks.com/topic/120954-solved-showing-date-from-mysql/#findComment-623581 Share on other sites More sharing options...
arn_php Posted August 23, 2008 Author Share Posted August 23, 2008 Thanks man! (how do I mark this post as it is SOLVED?) Link to comment https://forums.phpfreaks.com/topic/120954-solved-showing-date-from-mysql/#findComment-623582 Share on other sites More sharing options...
JasonLewis Posted August 23, 2008 Share Posted August 23, 2008 Bottom left of the page, down near Jump To. You'll find it. Link to comment https://forums.phpfreaks.com/topic/120954-solved-showing-date-from-mysql/#findComment-623585 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.