Jump to content

date help...countdown to expiary


shane85

Recommended Posts

hey guys...I made a post on this few days ago but still am unsure on how I should do this, or for that matter what would be the best way. open to suggestions.

 

what im doing is basically I have a form that submits to a database. One of the fields in my form is "contact_next", which is a drop down menu to chose from. The options are 1 day, 2 day, 3 day, 1 wk, 2 wk, 3 wk, 1 month, 2 month, 3 month, 6 month

 

I also have it storing a timestamp of when this entry is added. So I have a time stamp of when added, and when to contact next. So id imagine I would do a time - contact_next? Or something like that - because I have an option when viewing my entrys "View by when to Contact Next" say I have 4 records that are suppost to be viewed in 1 day, so for 1 day those records will be displayed first before the records from 2 days, 3 days etc. Im not sure how to store the "contact_next" in the database to do it properly to fetch the information.

 

thanks

Link to comment
Share on other sites

hmm

 

I tried your code and tried to echo days and it displayed 23, which is correct and what I want. However when I entered my variables it displayed a wierd number...my code is as follows

 

	  <?php
  $today=$arrEntry['tstamp'];
  $time_next=$arrEntry['contact_next'];
  $timediff=(strtotime($time_next)-strtotime($today));
  $minutes=$timediff/60;
  $hours=$minutes/60;
  $days=ceil($hours/24);
  
  echo $days;
      ?>

 

it displayed 14888 as the number of days...in my db, tstamp is 2010-04-05 15:37:54 and contact_next is 2010-10-05

 

does it matter that in my db for tstamp time is recorded as well? or its only looking at the date?

Link to comment
Share on other sites

now it displays -14704

 

	  <?php
  $today=$arrEntry['tstamp'];
  $time_next=$arrEntry['contact_next'];
  $timediff=(($time_next)-($today));
  $minutes=$timediff/60;
  $hours=$minutes/60;
  $days=ceil($hours/24);
  
  echo $days;
      ?>

Link to comment
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.