Hello.
I have a website with php in it but I cannot write php at all and have long lost touch with the one person I knew who understood it.
It was fine until my webhost updated from PHP 5.1 to PHP 5.3.
After he did that, all pages using code referring to dates messed up completely. It seems the date format that worked in 5.1 does not work in 5.3 and needs written a different way
Can anyone, please, tell me how the 5.1 version of the three pieces of code below should be written so that they will work in 5.3? I have no idea what to do to them. At the moment all I could do is completely remove that code from the files to get the site to work again but I would like to put it back, if it can be changed to work in 5.3, because it is very useful.
I’m in UK, in case that is required for the new code.
Many thanks to anyone who can help.
First one
<?php echo date('Y'); ?>
Second one
[code]// is item new on site?
//$today=date("Y-m-d");
$compareDate1=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-28,date("Y")));
// -28 = 4 weeks
$compareDate2=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-21,date("Y")));
// -21 = 3 weeks
$compareDate3=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-14,date("Y")));
// -14 = 2 weeks
$compareDate4=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-7,date("Y")));
// -7 = 1 weeks
// is it newer than 4 weeks?
if ($pd_date > $compareDate4)
{
echo "<br /><img src='images/new1.gif' alt='new' /><br />";
}
// is it newer than 3 week?
elseif ( $pd_date > $compareDate3)
{echo "<br /><img src='images/new2.gif' alt='new' /><br />";
}
// is it newer than 2 weeks?
elseif ($pd_date > $compareDate2)
{echo "<br /><img src='images/new3.gif' alt='new' /><br />";
}
// is it newer than 1 week?
elseif ( $pd_date > $compareDate1)
{echo "<br /><img src='images/new4.gif' alt='new' /><br />";
}
[/code]
Third one
[code]//$today=date(“Y-m-d”);
$compareDate1=date(“Y-m-d”,mktime(0,0,0,date(“m”),date(“d”)-28,date(“Y”))); // -28 = 4 weeks
$compareDate2=date(“Y-m-d”,mktime(0,0,0,date(“m”),date(“d”)-21,date(“Y”))); // -21 = 3 weeks
$compareDate3=date(“Y-m-d”,mktime(0,0,0,date(“m”),date(“d”)-14,date(“Y”))); // -21 = 3 weeks
$compareDate4=date(“Y-m-d”,mktime(0,0,0,date(“m”),date(“d”)-7,date(“Y”))); // -21 = 3 weeks
// is it newer than 4 weeks?
if ($pd_date > $compareDate4)
{echo “
”;
}
// is it newer than 3 weeks?
elseif ($pd_date > $compareDate3)
{echo “
”;
}
// is it newer than 2 weeks?
elseif ($pd_date > $compareDate2)
{echo “
”;
}
// is it newer than 1 week?
elseif ( $pd_date > $compareDate1)
{echo “
”;
}
[/code]
Thank you for looking.
Regards,
Cerio