-2

I have an error after change the host: on my Wordpress website.

Strict Standards: date(): 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 'Europe/Berlin' for 'CET/1.0/no DST' instead in /homepages/42/d545555785/htdocs/lifetips.ro/baby-gender-predictor.php on line 69

Strict Standards: date(): 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 'Europe/Berlin' for 'CET/1.0/no DST' instead in /homepages/..../htdocs/lifetips.ro/baby-gender-predictor.php on line 76

Strict Standards: 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 'Europe/Berlin' for 'CET/1.0/no DST' instead in /homepages/..../htdocs/lifetips.ro/baby-gender-predictor.php on line 82

Strict Standards: 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 'Europe/Berlin' for 'CET/1.0/no DST' instead in /homepages/..../htdocs/lifetips.ro/baby-gender-predictor.php on line 82

Generated in this ca. 200 lines of code:

<?php
/* This predictor is your for free by EverydayVBabies.com. You have no obligations for anything - you can modify, redistribute, sell it or whatever you want to do.
We will appreciate if you don't remove the link at the bottom, but that's not required. */

/* Feel free to modify the CSS and the texts below. - no problem at all. Just don't touch the PHP code or the specual codes which are surrounded with %% unless you know what you are doing. */
error_reporting(E_ALL&(~E_NOTICE));
@session_start();
?>
<style type="text/css">
.calculator_div
{
    font-family:verdana, arial, sans-serif;
    border:2pt solid #FF44FF;
    padding:25px;
    width:250px;
    margin:auto;
}

label
{
    display:block;
    float:left;
    width:150px;        
}
</style>
<?php
// present the calculator table as multi-dimentional PHP array
$table=array(
    "18"=>array("",'f','m','f','m','m','m','m','m','m','m','m','m'),
    "19"=>array("",'m','f','m','f','f','m','m','m','m','m','f','f'),
    "20"=>array("",'f','m','f','m','m','m','m','m','m','f','m','m'),
    "21"=>array("",'m','f','f','f','f','f','f','f','f','f','f','f'),
    "22"=>array("",'f','m','m','f','m','f','f','m','f','f','f','f'),
    "23"=>array("",'m','m','f','m','m','f','m','f','m','m','m','f'),
    "24"=>array("",'m','f','m','m','f','m','m','f','f','f','f','f'),
    "25"=>array("",'f','m','m','f','f','m','f','m','m','m','m','m'),
    "26"=>array("",'m','f','m','f','f','m','f','m','f','f','f','f'),
    "27"=>array("",'f','m','f','m','f','f','m','m','m','m','f','m'),
    "28"=>array("",'m','f','m','f','f','f','m','m','m','m','f','f'),
    "29"=>array("",'f','m','f','f','m','m','m','m','m','f','f','f'),
    "30"=>array("",'m','f','f','f','f','f','f','f','f','f','m','m'),
    "31"=>array("",'m','f','m','f','f','f','f','f','f','f','f','m'),
    "32"=>array("",'m','f','m','f','f','f','f','f','f','f','f','m'),
    "33"=>array("",'f','m','m','m','f','f','f','m','f','f','f','m'),
    "34"=>array("",'m','f','m','f','f','f','f','f','f','f','m','m'),
    "35"=>array("",'m','m','f','m','f','f','f','m','f','f','m','m'),
    "36"=>array("",'f','m','m','f','m','f','f','f','m','m','m','m'),
    "37"=>array("",'m','f','m','m','f','m','f','m','f','m','f','m'),
    "38"=>array("",'f','m','f','m','m','f','m','f','m','f','m','f'),
    "39"=>array("",'m','f','m','m','m','f','f','m','f','m','f','f'),
    "40"=>array("",'f','m','f','m','f','m','m','f','m','f','m','f'),
    "41"=>array("",'m','f','m','f','m','f','m','m','f','m','f','m'),
    "42"=>array("",'f','m','f','m','f','m','f','m','m','f','m','f'),
    "43"=>array("",'m','f','m','f','m','f','m','f','m','m','m','m'),
    "44"=>array("",'m','m','f','m','m','m','f','m','f','m','f','f'),
    "45"=>array("",'f','m','m','f','f','f','m','f','m','f','m','m')
);

$new_years=array("2014"=>"January 31, 2014", "2015"=>"February 19, 2015", "2016"=>"February 9, 2016",
"2017"=>"January 28, 2017", "2018"=>"February 16, 2018", "2019"=>"February 5, 2019",
"2020"=>"January 25, 2020");

if(!empty($_POST['calculator_ok']))
{
    // save in session to be used when the link "calculate again" is clicked
    foreach($_POST as $key=>$var) $_SESSION["calc_".$key]=$var;
    
    // calculate mother's lunar age
    if (date("n") <= $_POST['month'])
    {
        // conceived this year
        $year_conceived=date("Y")-1;        
    }
    else 
    {
        $year_conceived=date("Y");      
    }
    
    $new_year=$new_years[$year_conceived];      
    
    // should I add 1 or 2 years to age?
    if(strtotime($new_year)>strtotime($year_conceived."-".$_POST["month"]."-01"))   
    {
        $addition=1;
    }
    else $addition=2;
    
    $lunar_age=$_POST['age']+$addition;
    
    // calculate the result     
    $result=$table[$lunar_age][$_POST['month']];
    
    $gender=($result=='f')?"<span style=\"font-size:21px;font-weight:bold;color:pink;\">Girl</a></span>":"<span style=\"font-size:21px;font-weight:bold;color:lightblue\">Boy</span>";

    //the result is here
    ?>
    <div class="calculator_div">
    <p align="center">Your lunar age of conception is <b><?=$lunar_age?></b>.</p>
    <p align="center">You kid is most likely to be a <?=$gender?></p>
    <p align="center"><a href="http://<?=$_SERVER['HTTP_HOST'];?><?=$_SERVER['REQUEST_URI']?>">Calculate again</a></p>
    </div>
    <?php
}
else
{
    //the calculator comes here
    ?>
    <div class="calculator_div">
    <form method="post">
    <p><label>Your age of conception:</label> <select name="age">
    <?php for($i=16;$i<=43;$i++): 
    if($i==$_SESSION['calc_age']) $selected='selected';
    else $selected='';
    echo "<option $selected value='$i'>$i</option>";
    endfor ?>
    </select></p>
    
    <p><label>Month of conception:</label> <select name="month">
    <option value="1" <?if($_SESSION['calc_month']==1) echo "selected"?>>January</option>
    <option value="2" <?if($_SESSION['calc_month']==2) echo "selected"?>>February</option>
    <option value="3" <?if($_SESSION['calc_month']==3) echo "selected"?>>March</option>
    <option value="4" <?if($_SESSION['calc_month']==4) echo "selected"?>>April</option>
    <option value="5" <?if($_SESSION['calc_month']==5) echo "selected"?>>May</option>
    <option value="6" <?if($_SESSION['calc_month']==6) echo "selected"?>>June</option>
    <option value="7" <?if($_SESSION['calc_month']==7) echo "selected"?>>July</option>
    <option value="8" <?if($_SESSION['calc_month']==8) echo "selected"?>>August</option>
    <option value="9" <?if($_SESSION['calc_month']==9) echo "selected"?>>September</option>
    <option value="10" <?if($_SESSION['calc_month']==10) echo "selected"?>>October</option>
    <option value="11" <?if($_SESSION['calc_month']==11) echo "selected"?>>November</option>
    <option value="12" <?if($_SESSION['calc_month']==12) echo "selected"?>>December</option>
    </select></p>

    <div style="text-align:center;clear:both;"><input type="submit" value="Calculate!"></div>
    <input type="hidden" name="calculator_ok" value="1">
    </form> 
    <p style="text-align:center;font-size:11px;"><a href="http://everydaybabies.com">Baby Photo Contest</a></p>

    </div>
    <?php
}
?>
Community
  • 1
  • 1
Kreator
  • 1
  • 1
  • 2

2 Answers2

1

It is exactly what the error says: you are using the date() function without providing a timezone, which, according to PHP, can cause time errors.

And indeed, in this line:

if (date("n") <= $_POST['month'])

the date() function is called, but no timezone is set.

If you have control over your php.ini settings, just add the line

date.timezone=<your_default_timezone_identifier>

Otherwise, if you cannot modify php.ini, just add the line

date_default_timezone_set("<your_default_timezone_identifier>");

on the top of your page.

MC Emperor
  • 22,334
  • 15
  • 80
  • 130
0

Those are not errors, just warnings. Set suitable date.timezone value in php.ini according to your location and restart your webserver.

Daniel Gadawski
  • 1,893
  • 4
  • 20
  • 32