Jump to content

simple date format error


hoogie

Recommended Posts

Hi,

 

I'm having a strange problem formatting dates.  I'm looping through an array of dates from a database.  If I do it this way:

 

<?php

 

foreach ($date_array as $d) {

    echo date($d);

}

 

?>

 

I get a bunch of 2008-02-15s, which is the correct date.  However, I only want the day number, so I write it like this:

 

<?php

 

foreach ($date_array as $d) {

    echo date("d", $d);

}

 

?>

 

This returns a bunch of 31s.  Upon further investigation, I realized that when I try to format the date it returns December 31, 1969, no matter what my variable date is.  I've done some google searching, and as far as I can tell I'm writing the code right, so I'm not sure what the problem is.

 

I'm running

XAMPP for Linux 1.6.5a

PHP 5.2.5

MySQL 5.0.51

 

I have a feeling there is a simple answer to this question but I have been unable to find it.  Thanks for your help.

Link to comment
Share on other sites

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.