Jump to content

Recommended Posts

Something like this.

 

<?php

$day = date("d",$strtotime("+5 days",$database_timestamp);
$month = date("m",$database_timestamp);
$year = date("y",$database_timestamp);

$expire = mktime(0,0,0,$month,$day,$year);

if (time() < $expire) 
{
  // show button
}

?>

 

Compare the $expire date to the current date..

Link to comment
https://forums.phpfreaks.com/topic/66800-date-expiration-help/#findComment-334743
Share on other sites

better to use sql i guess

 

where etc....datediff(now(),'2004-10-10') >5

 

Lol, I'm always coming out with these elaborate ideas, then there turns out to be like.. a one line method of doing it.

The only thing I'm able to output using my cms software is the date format

 

You should be in the PHP, not the CMS ??

Link to comment
https://forums.phpfreaks.com/topic/66800-date-expiration-help/#findComment-334756
Share on other sites

better to use sql i guess

 

where etc....datediff(now(),'2004-10-10') >5

 

Lol, I'm always coming out with these elaborate ideas, then there turns out to be like.. a one line method of doing it.

The only thing I'm able to output using my cms software is the date format

 

You should be in the PHP, not the CMS ??

 

Yea I'm in php, I'm just lost on how exactly to use your code because I'm new at using this. For example my cms template variables are <Field: TwoDigitMonth>-<Field: TwoDigitDay>-<Field: TwoDigitYear> will display 08-26-07 if a post was posted today. I'm lost on where I'm suppose to put those variables I just listed in your code. Thanks for the help on this so far, appreciate it.

Link to comment
https://forums.phpfreaks.com/topic/66800-date-expiration-help/#findComment-334760
Share on other sites

I'm wanting to have a button on my website for each blog post, however if the blog post is 5 days old it will not display the button on the page. What would be the best way to do this?

 

in your question you only need this and i guess its the best

where etc....datediff(now(),'2004-10-10') >5

 

because you will only limit your output to those less than 5 days that code i gave you will limit it and you dont need to add something simply modify your query and add that

 

Link to comment
https://forums.phpfreaks.com/topic/66800-date-expiration-help/#findComment-334765
Share on other sites

This isn't exactly for blogs. This is for something else, it creates a .php page when information is submitted. What I am looking for is something when you insert the date 08-26-07 it will show something for 5 days, after 5 days that button will expire and not show anymore.

Link to comment
https://forums.phpfreaks.com/topic/66800-date-expiration-help/#findComment-334808
Share on other sites

 

 

You should be in the PHP, not the CMS ??

 

i believe CMS is done by php here i dont get you guys????

 

I don't get why he's using template variables.. think about it, it sounds like he's using a .tpl in something like phpbb.. .tpl can't process php.

Link to comment
https://forums.phpfreaks.com/topic/66800-date-expiration-help/#findComment-334955
Share on other sites

Below is something I'm doing myself, it's what I'm looking for. I don't have it working yet but maybe someone can help me.

 

<?php

$date1 = mktime(0,0,0,09,01,2007) - mktime(0,0,0,09,10,2007);
$date2 = "432000";


if ($date1 < $date2)
{
echo "Not Expired";
}
else
{
echo "Expired";
}
?> 

Link to comment
https://forums.phpfreaks.com/topic/66800-date-expiration-help/#findComment-334991
Share on other sites

Below is something I'm doing myself, it's what I'm looking for. I don't have it working yet but maybe someone can help me.

 

<?php

$date1 = mktime(0,0,0,09,01,2007) - mktime(0,0,0,09,10,2007);
$date2 = "432000";


if ($date1 < $date2)
{
echo "Not Expired";
}
else
{
echo "Expired";
}
?> 

 

That is essentially what mine did.  Look:

<?php
// This code here is used so we can prepare for the make time function.
// This date function takes the day that the blog was created on, an adds 5 days to it, moving over to the next month or even next 
// year if it needs.
$day = date("d",$strtotime("+5 days",$database_timestamp);
$month = date("m",$strtotime("+5 days",$database_timestamp));
$year = date("y",$strtotime("+5 days",$database_timestamp));
// This is the data that the button should not longer appear after
$expire = mktime(0,0,0,$month,$day,$year);
// This compares the current time, time(), with the expiration time and the displays the button if it hasn't expired.
if (time() < $expire) 
{
  // show button
}

?>

Link to comment
https://forums.phpfreaks.com/topic/66800-date-expiration-help/#findComment-335021
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.