CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Get Current Date/Time

Print topic Send  topic

Author Message
datadoit.com
Posted: 08/14/2007, 5:00 PM

CCS 3.1; PHP5.1; MySQL 5.1

I have a form, and on that form I have a hidden field with a control
source to a field called 'updated_date'. The field is defined as DATETIME.

I want that field to default to the current date and time, so when the
record is updated, this field gets written with the current date/time.

Without changing the field definition, what is the easiest way to get
the current date/time? Here's what DID NOT work, with the properties
for the field in CCS set to Data Type of Date, Format of GeneralDate,
DBFormat of yyyy-mm-dd HH:nn:ss :

a) In the Data tab, Default Value, setting to CurrentDateTime.
b) In the Events tab, Before Show, Retrieve Value for Control, type
Expression and Source Name to date('Y-m-d H:n:s'), or time(), or getdate().

I would think that this is a simple setting, without a lot of custom
coding CCFormatDate/CCParseDate, or Custom Update, etc. What am I missing?

thnx.
DonP
Posted: 08/14/2007, 5:59 PM

You may be able to simply put the mktime() function in the field's
Properties but generally I create a Before Show event for the field and add
the code there. I usually set the field to Int and use the Unix Timestamp as
it's easier for me to work with than regular date/time fields. mktime() adds
the Unix Timestamp.

Don

"datadoit.com" <datadoit@forum.codecharge> wrote in message
news:f9tfmu$srf$1@news.codecharge.com...
> CCS 3.1; PHP5.1; MySQL 5.1
>
> I have a form, and on that form I have a hidden field with a control
> source to a field called 'updated_date'. The field is defined as
> DATETIME.
>
> I want that field to default to the current date and time, so when the
> record is updated, this field gets written with the current date/time.
>
> Without changing the field definition, what is the easiest way to get the
> current date/time? Here's what DID NOT work, with the properties for the
> field in CCS set to Data Type of Date, Format of GeneralDate, DBFormat of
> yyyy-mm-dd HH:nn:ss :
>
> a) In the Data tab, Default Value, setting to CurrentDateTime.
> b) In the Events tab, Before Show, Retrieve Value for Control, type
> Expression and Source Name to date('Y-m-d H:n:s'), or time(), or
> getdate().
>
> I would think that this is a simple setting, without a lot of custom
> coding CCFormatDate/CCParseDate, or Custom Update, etc. What am I
> missing?
>
> thnx.

datadoit.com
Posted: 08/14/2007, 7:11 PM

DonP wrote:
> You may be able to simply put the mktime() function in the field's
> Properties but generally I create a Before Show event for the field and add
> the code there. I usually set the field to Int and use the Unix Timestamp as
> it's easier for me to work with than regular date/time fields. mktime() adds
> the Unix Timestamp.
>
> Don
>
-------------------------

That was dead-on Don! Before Show event for the hidden field, Retrieve
Value for Control, Source Type Expression, and Source Name mktime().

Thanks!
DonP
Posted: 08/14/2007, 7:43 PM

Glad it worked for you!

Don

"datadoit.com" <datadoit@forum.codecharge> wrote in message
news:f9tncl$1br$1@news.codecharge.com...
> DonP wrote:
>> You may be able to simply put the mktime() function in the field's
>> Properties but generally I create a Before Show event for the field and
>> add the code there. I usually set the field to Int and use the Unix
>> Timestamp as it's easier for me to work with than regular date/time
>> fields. mktime() adds the Unix Timestamp.
>>
>> Don
>>
> -------------------------
>
> That was dead-on Don! Before Show event for the hidden field, Retrieve
> Value for Control, Source Type Expression, and Source Name mktime().
>
> Thanks!

montymoose


Posts: 85
Posted: 08/15/2007, 3:08 AM

The best way is to create a label which is not within any grid. Set the type to date, and set Default value as Current Date.

Moose
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.