0

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

4
Contributors
5
Replies
7
Views
5 Years
Discussion Span
Last Post by kelvinejimogu
0

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

0

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

0

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"]));

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.