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

 Set todays date before show in a hidden field

Print topic Send  topic

Author Message
jemke

Posts: 5
Posted: 02/28/2006, 12:16 PM

This should be simple but it just doesn't want to work for me.

I am using PHP and MySql and CCS 2.last (Haven't converted this client to CCS 3.0 yet too much descrete code to change)

I cannot use the MySql timestamp function because there already is a field that timestamps changes to this table. This field is a tickler that will be used to alert users of a timed event. It will be reset each time a new event is begun.

Here is the code block:

global $claims;
$claims->tickler_date->SetValue(GetDate("m/d/Y"));

Here is the error message:
The value in field tickler_date is not valid. Use the following format: mm/dd/yyyy. This format in a GetDate("mm/dd/yyyy") produces the same error message.

If I do this:
global $claims;
$claims->tickler_date->SetValue(Date("m/d/Y"));

or this:

global $claims;
$claims->tickler_date->SetValue(Date("mm/dd/yyyy"));

I do not get the message but it saves: "1969-12-31 00:00:00" in the file instead of todays date.

What I would really like to do is save a date that is 15 days in the future to todays date but I can't seem to get todays date to save let alone a furure date.

Any help would be greately appreciated.

Mike Scott

View profile  Send private message
mfratto

Posts: 34
Posted: 02/28/2006, 12:31 PM

Mike, did you make sure in the project Settings that the Date Display Format is correct? Same for the hidden field. That is the usually the cause of the funky date your seeing, IIRC.
View profile  Send private message
mamboBROWN


Posts: 1713
Posted: 02/28/2006, 12:50 PM

jemke
Here are two ways to get the current date:
1.
global $claims;
$today = getdate();
$mm = $today[month];
$dd = $today[mday];
$yy = $today[year];
$hr = $today[hours];
$mn = $today[minutes];
$sec = $today[seconds];
$str_today = $mm."-".$dd."-".$yy." ".$hr.":".$mn.":"$sec;
// $str_today should give you 02-28-2005 03:39:00
$claims->tickler_date->SetValue($str_today );

2. In the date fields data property default value set it to CurrentDateTime and it will grab the system current date and time and don't forget to set the DBFormat data property to the correct format.

Hope this helps.......
View profile  Send private message
wkempees
Posted: 02/28/2006, 12:58 PM

instead off getdate use date()
$claims->tickler_date->SetValue( date("m/d/Y") );
Check the project and database setting for you date fields, as suggested
earlier.
Also post here the type and settings of the field tickler

The following piece of code will give you 15 days ahead of today's date:
  
echo date('d/m/Y'); // display today's date in dd/mm/yyyy  
$year = substr(date('Y/m/d'), 0, 4);    // notice the different format  
$month = substr(date('Y/m/d'), 5, 2);  
$day = substr(date('Y/m/d'), 8, 2);  
$t1 = mktime(0, 0, 0, $month, $day, $year); // builds a timestamp.  
echo $t1 .' ';    // just to show you what a time stamp looks like  
echo Date("d-m-Y",$t1). '<br>';  // prove it is stil okay,  
  
$t1 = mktime( date('h', $t1),                // add 15 to the 'd' day   
parameter  
              date('i', $t1),                // this will cater for month's   
and year's end  
              date('s', $t1),                //  
              date('m', $t1),  
              date('d', $t1) + 15,  
              date('Y', $t1)  
             );  
echo $t1 .'<br>';                            // show the new timestamp, not   
that it's any use (no of seconds since ...)  
echo Date("d-m-Y",$t1);                      // show the date 15 days from   
NOW  

Of course you have to cater for the correct date formats, without messing up
the calculation bit.

BTW Getdate() returns an array where your field expects a string.

Your coee would have to be something like:

  
$year  = substr(date('Y/m/d'), 0, 4);    // notice the different format  
$month = substr(date('Y/m/d'), 5, 2);  
$day   = substr(date('Y/m/d'), 8, 2);  
$t1    = mktime(0, 0, 0, $month, $day, $year); // builds a timestamp.  
$t1 = mktime( date('h', $t1),                // add 15 to the 'd' day   
parameter  
              date('i', $t1),                // this will cater for month's   
and year's end  
              date('s', $t1),                //  
              date('m', $t1),  
              date('d', $t1) + 15,  
              date('Y', $t1)  
             );  
  
$claims->tickler_date->SetValue( date("m/d/Y",$t1) );  

wkempees
Posted: 02/28/2006, 1:00 PM

@MB
you beat me to it by 3 minutes, aren't we a great team?
mamboBROWN


Posts: 1713
Posted: 02/28/2006, 1:09 PM

wkempees
Yes we are!!!;-)
View profile  Send private message
wkempees


Posts: 1679
Posted: 02/28/2006, 1:09 PM

8-)
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
peterr


Posts: 5971
Posted: 02/28/2006, 1:56 PM

You are! :-)
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Damian Hupfeld
Posted: 02/28/2006, 2:42 PM

I have to tell you that an active forum like this adds significant value to
your product.

Damian

"peterr" <peterr@forum.codecharge> wrote in message
news:54404c6fe9330d@news.codecharge.com...
> You are! :-)
> _________________
> Peter R.
> YesSoftware Forums Moderator
> For product support please visit http://support.yessoftware.com
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

jemke

Posts: 5
Posted: 02/28/2006, 4:00 PM

Thanks Guys,

What a great response.

Will try them all.

Mike
View profile  Send private message
Last Hero
Posted: 03/01/2006, 1:33 AM

CCS3 only:

$date = CCGetDateArray();
$new_date = CCDateAdd($date , "+15 days");

$string = CCFormatDate($new_date, array("GeneralDate"));
Mscott
Posted: 03/01/2006, 10:12 AM

Looks like a much more elegant way to deal with dates - more incentive to convert this solution to CCS3 but the conversion fails miserably because of all the descrete code in it and the solution got put into service before it was complete because of the late season hurricane here in Florida. As soon as I can I will have to try to convert it again.

Thanks,

Mike

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.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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