mullberrymae Posted April 20, 2011 Share Posted April 20, 2011 why does this : $date = date('m d,Y', "$postdate"); work to format my date output on one page yet on the other I get the dec 31 1969 output for all my dates? Quote Link to comment https://forums.phpfreaks.com/topic/234203-date-format-works-on-one-page-not-the-other/ Share on other sites More sharing options...
spiderwell Posted April 20, 2011 Share Posted April 20, 2011 hang on, I'll just get my crystal ball post the relevant code please Quote Link to comment https://forums.phpfreaks.com/topic/234203-date-format-works-on-one-page-not-the-other/#findComment-1203790 Share on other sites More sharing options...
PFMaBiSmAd Posted April 20, 2011 Share Posted April 20, 2011 Have you checked if $postdate has a value at all or has an expected value (unix timestamp) in it? Quote Link to comment https://forums.phpfreaks.com/topic/234203-date-format-works-on-one-page-not-the-other/#findComment-1203792 Share on other sites More sharing options...
mullberrymae Posted April 20, 2011 Author Share Posted April 20, 2011 Thanks for responding. when I echo $posdate I get a date like this: 2011-04-14 I just want to format that to m d y $sqlgb ="SELECT * FROM `guestbook`, `obituaries` WHERE guestbook.obits_id = '$id' "; $results=mysql_query($sqlgb) or die("Error: ". mysql_error(). " with query ". $sqlgb); $num = mysql_num_rows($results); if ($num > 0 ) { $i=0; while ($i < $num) { $id = mysql_result($results,$i,"id"); $obits_id = mysql_result($results, $i, "obits_id"); $name = mysql_result($results,$i,"name"); $email = mysql_result($results,$i,"email"); $message = mysql_result($results, $i, "message"); $postdate = mysql_result($results,$i,"postdate"); $date = date('m d,Y', "$postdate"); thats the code block I'm using Quote Link to comment https://forums.phpfreaks.com/topic/234203-date-format-works-on-one-page-not-the-other/#findComment-1203796 Share on other sites More sharing options...
PFMaBiSmAd Posted April 20, 2011 Share Posted April 20, 2011 The only way your code would have worked on any page with the value you have shown for $postdate, would be if you used the following - $date = date('m d,Y', strtotime($postdate)); Quote Link to comment https://forums.phpfreaks.com/topic/234203-date-format-works-on-one-page-not-the-other/#findComment-1203944 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.