CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.

YesSoftware Forums -> CodeCharge Studio -> PHP

 Resolved: Return largest of three dates

Print topic Send  topic

Author Message

Posts: 868
Posted: 05/23/2008, 11:23 PM

Hi all. Struggling with this code.
I have three dates in hidden fields on a grid. I need to set the label 'start_date' to the largest of the three dates.
Here is what I have:

 $Container->enr_date->SetValue(( strtotime(CCFormatDate($Container->enr_date->GetValue(),array("yyyy", "-",  
"mm", "-", "dd")))  ) / 86400);  
$Container->term_date->SetValue(( strtotime(CCFormatDate($Container->term_date->GetValue(),array("yyyy", "-",  
"mm", "-", "dd")))  ) / 86400);  
$Container->mydate->SetValue(( strtotime(CCFormatDate($Container->mydate->GetValue(),array("yyyy", "-",  
"mm", "-", "dd")))  ) / 86400);  
$final_date= max( array($Container->enr_date->Getvalue() , $Container->term_date->GetValue(), $Container->mydate->GetValue()) );  

I get an error (testing on local machine): Notice: strtotime(): Called with empty time parameter in c:\inetpub\wwwroot\cavatesttest\teacher\print_fall_init_isma2_events.php on lines 22,24,26

The start_date is being set to: 1969-12-31

When I echo the results I see a string like this: 14022.2916667
When I display the hidden fields as lavbels, they display fine.

All labels are set to Date, format yyyy-mm-dd

Using Mysql 4.0

I assume I am formatting the date strings incorrectly... but other than that I am lost.


Walter are dearly missed.
View profile  Send private message

Posts: 942
Posted: 05/24/2008, 8:21 AM


There is a undocumented aspect to date controls in CCS i discovered. (At least I could find no documentation on this).

If all your dates are stored in CCS controls defined as dates instead of text or you have a hidden field defined as a date field you can do this to get the dates into a timestamp format so you can do a mathematical compare.

example 1.
You create a Text Box Control (You can hide it or display it but it must be visible)
Set the data type to date
Select the date format (This way your code adjusts automatically to what ever format you want)
Select the DBformat Appropriately.

Once a date is in the control the control will return an array when retrieved. Each array element is part of the foprmatted date per the format for the control. However index [0] contains the timestamp for the date regardless of the display format.

So... Where each my_date control is a control set up as above..


Arrays $date1[0] and $date2[0] now contain timetamp for the dates as integers and you can do mathematical compares.

eg: if($date1[0] > $date2[0]){DO SOMETHING;}else{DO THIS;}

There is another trick you can try if you only have the dates in a string format like "mm/dd/yyyy"
(useful is dates are comming from a url parameter or some other source as a text string)

Create a hidden text box control configured as above setting the date display format you expect the input string to be as a date.

In the after initialize event or before show event fdo the following for each text string date needed.

$Container->input_date->SetText($Input_Text_String); // Note use SetText() not SetValue()
$my_compare_date1=$Container->input_date->GetValue();// Using GetValue() returns the date array as described above for your input date text string CCS converts it for you.

Do this for each text input date and you will now have timestamps for each date that you can do your math compares on.

Hope that Helps.

John Real - More CodeCharge Studio Support at -
View profile  Send private message

Posts: 868
Posted: 05/24/2008, 11:49 AM

Walter are dearly missed.
View profile  Send private message
Posted: 05/25/2008, 9:42 AM

Spectacular information John!

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

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login

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