Hi guys,

I have this error :

Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /home/kelvinej/public_html/index.php on line 21

And this is line 21 in my code :

$date_added = strftime("%b %d, %Y",strtotime($row["date_added"]));

can anyone help me on this please

Thanks guys

Why do you use the strtotime() and not date() ?

I thought i should copy paste the block of cod that i think is the problem

Here the code block :

<?php  
// Run a select query to get my letest 6 items
// Connect to the MySQL database  
include "storescripts/connect_to_mysql.php"; 
$dynamicList = "";
$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 6");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
    while($row = mysql_fetch_array($sql)){ 

             $id = $row["id"];

             $product_name = $row["product_name"];

             $price = $row["price"]; 

**Line 21**       $date_added = strftime("%b %d, %Y",strtotime($row["date_added"]));

             $dynamicList .= '<div  style="height:350px; padding-left:20px; float:left; ">
        <ul style="list-style-type:none; ">
          <li  width="17%" ><a href="product.php?id=' . $id . '"><img style="border:#666 0px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="200" height="250" border="1" /></a></li>
          <li width="83%" style=" padding-top:10px;" ><div style="height:8px;">' . $product_name . '</div><br /><div style="height:8px">
            $' . $price . '</div><br/>
            <a href="product.php?id=' . $id . '">View Product Details</a></li>
        </ul>
      </div>';
    }
} else {
    $dynamicList = "We have no products listed in our store yet";
}
mysql_close();
 ?> 

Please if you can show me exactly how to add your/above code to this , I'm a newbie
Thanks for you help

Add below line in top of php code. You can also set this value from php.ini.
date_default_timezone_set('America/New_York');

Thanks @vibhaJ it worked like charm on all the pages yeesss !!

Please one more thing, I would like to know why the below code didn't run could it be my system time setting .
Thanks again guys.

$date_added = strftime("%b %d, %Y",strtotime($row["date_added"]));

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.