ffxpwns Posted April 4, 2012 Share Posted April 4, 2012 I think its a problem connecting with mySQL, because no matter what I put in the "Date" category, it comes up as Dec 31. Here's the snippet in question for the newArticle.php, and the corresponding snippet for the homepage layout. If I could somehow put a "$today = date("F j, Y, g:i a");" at the top and replace that stuff with $today, please let me know! The column is called publicationDate, and its a VARCHAR with 30 length. And I'm 100% I'm connected to the DB itself, because articles will post correctly and they appear on both the webpage and their various rows. The only one thats not working is publicationDate. The 'write' part in newArticle.php <li> <label for="publicationDate">Publication Date</label> <input type="date" name="publicationDate" id="publicationDate" placeholder="MM-DD-YYYY, hh:mm" required maxlength="30" value="<?php echo $results['article']->publicationDate? date("F-j-Y-g:i a", $results['article']->publicationDate ) : "" ?>" /> </li> The 'read' part in the homepage <td><?php echo date("F j, Y, g:i a", $article->publicationDate)?></td> Quote Link to comment https://forums.phpfreaks.com/topic/260314-time-only-displaying-as-december-31-1969-400-pm/ Share on other sites More sharing options...
requinix Posted April 4, 2012 Share Posted April 4, 2012 The "1969 error" (as I call it) happens when you give date() something that isn't a Unix timestamp, or when you give strtotime() something that it can't parse as a date string. If you want to reformat the date string and you can't store it as a timestamp to begin with, run it through strtotime() first. date("format", strtotime($date_string)) Quote Link to comment https://forums.phpfreaks.com/topic/260314-time-only-displaying-as-december-31-1969-400-pm/#findComment-1334230 Share on other sites More sharing options...
iknowifail Posted April 4, 2012 Share Posted April 4, 2012 I made some suggestions on reddit for you http://www.reddit.com/r/PHP/comments/rsiop/time_only_displaying_as_december_31_1969_400_pm/c48fvwy. Please let me know if it helped. Quote Link to comment https://forums.phpfreaks.com/topic/260314-time-only-displaying-as-december-31-1969-400-pm/#findComment-1334460 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.