troubleshooting Question

PHP Date display - It's not 1969!!!

Avatar of Crys_Crys
Crys_Crys asked on
8 Comments1 Solution349 ViewsLast Modified:
(NOTE:  I am fairly new to PHP and most explainations will most likely confuse me alot, such as ones displayed on "helpful" tutorial sites.)

Here is my current code for inputting the date of the submit botton was pushed:


if(isset( $submit ))
$sql = mysql_query("INSERT INTO `blog` (`id`, `date_entered`) VALUES ('',  CURDATE( ))");

$query = "SELECT * FROM `blog`";
$data = mysql_query($query);
for($i=0;$i<mysql_num_rows($data);$i++) {
    $posts[$i]['date_entered'] = mysql_result($data, $i, 'date_entered');

if(count($posts)<7) {
$show_posts = count($posts);

for($i=0;$i<$show_posts;$i++) {

<table align="center" border="0" width="80%">

            <div align="right"><? echo $posts[$i]['date_entered'] ?></div>

<?php } ?>

<form method="post" action="login.php">
<input name="date_entered" type="hidden">
<input value="submit" name="submit" type="submit">


Ok, so here's a short history of my issue:

1.  Currently, the time will show up as, using today as an example, 2005-08-29.
2.  I've had people try to help me already, and suggested I use TIME() instead of CURDATE() and format the date where it's outputted now as DATE('l, F j, Y', $posts[$i]['date_entered']), but that only gives me: Wednesday, December 31, 1969.  It's the same if I just keep using CURDATE().
3.  DID NOT help me.  It only confused me more.
4. and have also just confused me more.
5.  I have tried making date_entered a varchar, date, datetime, int, and timestamp, as well as trying to output the date as unix_timestamp.  Those all give the same output.
6. I am running a while loop because this will be used for other scripts I have.  Most 'fetch' statements only give me loads of errors.

I have a feeling when I use DATE(), it's only reading the l,F j, Y as 0, therefore resetting the time to 1969.  I would like to display the date as, using today as an example:  Monday, August 29, 2005 if it is possible.  This seemed like a fairly simple issue at first, but

Thank you.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros