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
https://forums.phpfreaks.com/topic/90623-simple-date-format-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.