Hi every body

i made news page in my Dreamweaver project and i added the date and time by this code

$time=(date("l dS \of F Y h:i:s A") . "<br />"); it is work correctly but, i wanna post it into other page some things like showing added news and so, i wanna expire the time some things like comments function

hope some body help me

many thanks

Recommended Answers

All 2 Replies

You should really use timestamp. Makes it a lot easier to manipulate.

$cutoff = (cut off time you want it to stop);
$currenttime = time();
if ($cutoff > $currenttime) {
     // comments are disabled
}

1) when you save news also save expire date in database.e.g.
<?
$expDate = date('Y-m-d H:i:s', mktime(date("H"), date("i"), date("s"), date("m") , date("d")+7, date("Y"))); // expire after 7days
?>
2) where ever you are showing news in select query filter expire date for fetching news from db.e.g.
<?
$currDate = date('Y-m-d H:i:s');
$sql ="select * from news where expDate<='".$currDate."'";
?>

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.