Jump to content

Recommended Posts

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>

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))

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.