Ive got such script:
mysql_connect('localhost', 'xxx', 'xxx');
mysql_select_db('xxx');
$sql = "SELECT * FROM rl_cronjobs";
$sql = mysql_query($sql);
$row = mysql_fetch_array($sql);
$sunday = $row['next_sunday'];
$today = date('Y-m-d');
if($sunday == $today){
$sql = "DELETE * FROM xxx WHERE stala != 1";
$sql = mysql_query($sql);
echo $nextsunday;
$nextsunday = strtotime("next Sunday");
$nextsunday = date('Y-m-d', $nextsunday);
$sql = "UPDATE xxx SET next_sunday = $nextsunday";
$sql = mysql_query($sql) or die (mysql_error());
echo $nextsunday;
}
And in MySQL the value of it is: 1984
I need it to be normal date of next sunday
The type of MySQL table row is varchar because when i set tu date it doesn’t update. Any help?
Don’t store dates in varchar fields. Mysql has date, datetime, and timestamp fields for such things, and using them opens a world of new possibilities. E.g. your “next sunday” calculations can be done as simply as:
without ever involving the PHP time functions. Note that this particular function will always pick the real next sunday, so if you run this code on a Sunday, you’ll get the following weeks’ sunday, not “today”, e.g.:
As well, note that you’re trying to echo
$nextsundaybefore it’s been defined.