CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Date Stored + dateToday =

Print topic Send  topic

Author Message
SecureCloud


Posts: 51
Posted: 12/21/2012, 2:15 PM

my question is...
(using CCS5 + php)

how can i take a take a date stored in db example an expiration, ex. 10/20/2016
and calculate today's date, and if expiration is within 30 days show label ?

would i pre-make all my labels for each type of expiration ?

how would i go about something like that ??

or you could say if stored date is within 30 days of today display label...



_________________
-------------------------------------------------------------------------------------------------
If this helped You, Please Donate to SecureCloud Here, ANY amount Accepted.
http://securecloud.biz/donate/
Thank You, Your help Keeps us Going.

View profile  Send private message
MichaelMcDonald

Posts: 640
Posted: 12/21/2012, 4:33 PM

Have a look at strtotime and time()

http://php.net/manual/en/function.date.php

Convert datetimes to UNIX timestamp and perform calculations on the integers something like:


$timediff = $timestamp1 - $timestamp2;

If($timediff <= 30){
$container->label->Visible = true);
}

When you get it working, Change topic to "Resolved" and post results.
_________________
Central Coast, NSW, Australia.

View profile  Send private message
SecureCloud


Posts: 51
Posted: 12/21/2012, 8:06 PM


see, i am trying different ways.. ( I dont need time functions just date )

but i am trying to make it a general check 'template' that can be applied to different expirations.. as it will check multiple dates in different fields, or i can apply the code to each check... either way...
i think CCDLookUp is the way to go, read alot about it, but looks like a pain.

i would have to CCDLookUp each label, because this script is gonna run on the dashboard page
if expirations are within 30 days, show label or label(s)...

LOGIC EXAMPLE...NOT WORKING
  
// date stored like 2012-12-30  
// compare date stored as expiration, if within 30 days of today, visible=true..  
  
$exp = $Container->Label1->GetValue($value1);  
  
$today = date("Y-m-d");  
  
$totaldays = $exp - $today;  
  
if ($totaldays <= 30)  {  
  $container->Label1->Visible = true);  
}  
else  {  
  $container->Label1->Visible = false);  
}  

like i said i am trying different methods to do this
to apply it once or reuse it as a template for different fields


I have tried playing with this.... this works... but now gotta convert to CCS
  
$exp_date = "2012-12-31";  
$todays_date = date("Y-m-d");  
  
$today = strtotime($todays_date);         // 1356069600  
echo $today . " today<br>";  
  
$expiration_date = strtotime($exp_date);  // 1356933600  
echo $expiration_date . " expiration date<br>";  
  
$total= $expiration_date - $today;        // 864000  
echo $total . " total minus<br><br>";  
  
if ($total <= 2592000) {  
     echo $valid = "VISIBLE";  
} else {  
     echo $valid = "NOT-VISIBLE";  
}  

Quote :
OUTPUT
----------------------------------------
1356156000 today
1356933600 expiration date
777600 total minus

VISIBLE

so by changing the dates, if its within 30 days its VISIBLE - ( above example is 9 days away)
if its outside 30 days... its INVISIBLE



_________________
-------------------------------------------------------------------------------------------------
If this helped You, Please Donate to SecureCloud Here, ANY amount Accepted.
http://securecloud.biz/donate/
Thank You, Your help Keeps us Going.

View profile  Send private message
SecureCloud


Posts: 51
Posted: 12/21/2012, 10:33 PM

could someone else second this if it will work or not in CCS...??
i think i got it... as php it works (above code), after i converted it to CCS, haven't tested yet..

//  Label99_exp  has expiration date stored.. ex 2013-01-20  
  
$exp_date = $Container->Label99_exp->GetValue();    
$todays_date = date("Y-m-d");    
  
$today = strtotime($todays_date);  
  
$expiration_date = strtotime($exp_date);  
  
$total= $expiration_date - $today;  
  
//  30 days = 2592000   
if ($total <= 2592000) {    
     $container->Label_exp_1->Visible = true);  
} else {    
     $container->Label_exp_1->Visible = false);  
}


the first part of the IF, is if the value is within 30 days ?
else visible=false if date is further than 30 days...

i am asking ? any input ?? does this look right to you ??

i have also seen something like this...
echo strtotime("+30 days", $exp_date);  // 30 days from expiration date

any suggestions ??



_________________
-------------------------------------------------------------------------------------------------
If this helped You, Please Donate to SecureCloud Here, ANY amount Accepted.
http://securecloud.biz/donate/
Thank You, Your help Keeps us Going.

View profile  Send private message
bannedone


Posts: 273
Posted: 12/22/2012, 8:09 AM

Here is how dates are implemented in CCS controls

This should probably help U.

http://forums.yessoftware.com/posts.php?post_id=97052

Have Fun
8-)

_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.