lammy
Posts: 49
|
| Posted: 08/04/2008, 7:34 AM |
|
I have the following code within a record grid to set the lastupdate field to the current date.
global $golf3;
$golf3->lastupdate->SetValue(date("d.m.Y") );
all is ok with the update etc apart from on my local machine its selecting 01/01/1970
and when uplaoded to the server the date is 31/12/1969, as far as Im aware we are in 2008
could somebody assist as to why it isn't selecting the current date.
Thanks
Lammy
|
 |
 |
materix
Posts: 161
|
| Posted: 08/04/2008, 7:49 AM |
|
You need also to the set the correct DBFormat for the field.
|
 |
 |
lammy
Posts: 49
|
| Posted: 08/04/2008, 8:09 AM |
|
I think all settings are correct
in project settings I have dd/mm/yyyy
Grid
My field format is set to dd/mm/yyyy
My DB format is set to yyyy/mm/dd HH:nn:ss
Database Table
Table field that holds the date is DATE field.
as fare as I can see they all match up.
It saves the date in the field in my table .
the code is in before show event, if I type in a date to over ride the code
it does save the date that I have typed in.
Im at a loss.
Lammy
|
 |
 |
materix
Posts: 161
|
| Posted: 08/04/2008, 8:37 AM |
|
Ok.
What is the reason that you do not set default value for the field with the CurrentDate-function?
|
 |
 |
wkempees
Posts: 1679
|
| Posted: 08/04/2008, 8:58 AM |
|
Quote :
n project settings I have dd/mm/yyyy
Grid
My field format is set to dd/mm/yyyy
My DB format is set to yyyy/mm/dd HH:nn:ss
Max:
If database has yyyy/mm/dd HH:nn:ss shouldn't Connection Settings be yyyy/mm/dd HH:nn:ss as well?
making obsolete the field setting DB format yyyy/mm/dd HH:nn:ss.
I totaly agree on DateField Properties DefaultValue CurrentDate
Walter
_________________
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
|
 |
 |
lammy
Posts: 49
|
| Posted: 08/04/2008, 9:22 AM |
|
What is the reason that you do not set default value for the field with the CurrentDate-function?
There is a date already in the field, when somebody updates the record I need to update the date field to the current date, setting default currentdate doesn't change this. but saying that it is set to default CurrentDate.
I also have my connection set at yyyy/mm/dd HH:nn:ss
Thanks
Lammy
|
 |
 |
materix
Posts: 161
|
| Posted: 08/04/2008, 4:25 PM |
|
Quote :setting default currentdate doesn't change this
You are correct about this.
Try then instead:
$golf3->lastupdate->SetValue(date("Y-m-d") );
or
$golf3->lastupdate->SetValue(date("Y-m-d H:i:s") );
|
 |
 |
datadoit
|
| Posted: 08/04/2008, 6:26 PM |
|
Try SetValue(mktime());
|
|
|
 |
lammy
Posts: 49
|
| Posted: 08/05/2008, 12:52 AM |
|
Thanks for all the replies, I have managed to get it to work.
I changed this line
$golf3->lastupdate->SetValue(date("d.m.Y") );
to
$golf3->lastupdate->SetValue(date("d/m/Y") );
and changed the lastupdate field data type to text and it worked.
Thanks
Lammy
|
 |
 |
wkempees
Posts: 1679
|
| Posted: 08/05/2008, 3:26 AM |
|
lammy
Please change title to [Solved] Set Current Date
Walter
_________________
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
|
 |
 |
jjrjr1
Posts: 942
|
| Posted: 10/07/2008, 6:54 AM |
|
Hi
I would not recommend changing date fields from dates to text. Several reasons but one is you loose the ability to do easy date compares or date increments like say today + 30 days.
Here is a link for more date info and some undocumented features.
http://ccselite.com/forums_topics_view.php?forum_id=8&forum_topic_id=7
Have fun
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
CCSGuy
Posts: 5
|
| Posted: 10/07/2008, 10:51 AM |
|
lammy
If you would like to keep your feild as Date instead of Text you can change this line:
$golf3->lastupdate->SetValue(date("d/m/Y") );
to this line:
$golf3->lastupdate->SetValue(strtotime(date("d/m/Y")) );
In php date() returns a string so you need to use strtotime() to change it to an actual timestamp.
Hope that helps.
_________________
Continuous effort - not strength or intelligence - is the key to unlocking our potential.
Sir Winston Churchill
|
 |
 |
jjrjr1
Posts: 942
|
| Posted: 10/07/2008, 11:05 AM |
|
Hi
Actually you can use time(); . It retruns a unix timestamp.
Look here for info on CCS date and the time function etc:
http://ccselite.com/forums_topics_view.php?forum_id=8&forum_topic_id=7
Hope that helps a little.
Later
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |