datadoit.com
|
| Posted: 03/30/2005, 7:45 AM |
|
PHP4; CCS2.3; MySQL 3.2
I have literally spent HOURS on this trying to figure it out.
I have a form with a date field in it. The DB format is yyyy-mm-dd
HH:nn:ss. The project settings default is ShortDate. The form field Data
Type is Date.
In the fields BeforeShow event, I'm attempting to get a default database
value for the field from a lookup. However, just trying to set a manual
date via:
$form->datefield->SetValue("2005-03-30")
will show "12/31/69" in the field. I've even tried:
$form->datefield->SetValue(CCFormatDate(CCParseDate("2005-03-30",array("yyyy","-","mm","-","dd")),
array("ShortDate"))
which shows nothing in the form field.
What am I doing wrong? Thnx.
|
|
|
 |
lvalverdeb
Posts: 299
|
| Posted: 03/30/2005, 9:06 AM |
|
Hi,
I too got fed up with the 12/31/69 result. The following approach works for me:
$DateFromDB = "2003-03-30";
$dateParts = explode("-",$DateFromDB);
$timestamp = mktime(0,0,0,$dateParts[1],$dateParts[2],$dateParts[0]);
$form->datefield->SetValue($timestamp);
Luis
_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4 |
 |
 |
datadoit.com
|
| Posted: 03/30/2005, 1:06 PM |
|
> Hi,
>
> I too got fed up with the 12/31/69 result. The following approach works
> for
> me:
>
>
> $DateFromDB = "2003-03-30";
> $dateParts = explode("-",$DateFromDB);
> $timestamp = mktime(0,0,0,$dateParts[1],$dateParts[2],$dateParts[0]);
> $form->datefield->SetValue($timestamp);
>
>
> Luis
> ---------------------------------------
Wondermous! This work great.
It may take me a few more years and a few dozen more projects before I get a
grasp on how CCS is handling the display of dates. I've read through the
docs and my code, and for the life of me can't see why it doesn't work, or
rather comes up with that crazy 12/31/69 date (which by the way is my sis's
birthday).
|
|
|
 |
lvalverdeb
Posts: 299
|
| Posted: 03/30/2005, 2:04 PM |
|
Cheers Mike. I have a few projects that involve handling lots of date calculations and I also attempted to write wrappers to CCS's date functions without much success. Time constraints forced me to develop a small class library to manage date parsing, formatting, displaying and several types of calculations (date differences, date adding, etc). If you're interested in the source code, drop me an email at lvalverdeb@yahoo.com.
Luis
_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4 |
 |
 |
Last Hero
|
| Posted: 03/30/2005, 11:46 PM |
|
Right ways:
a)$form->datefield->SetText("2005-03-30") , when Controls Format = yyyy-mm-dd
b)$form->datefield->SetValue(CCParseDate("2005-03-30"), array("yyyy", "-", "mm", "-", "dd")), ColntrolsFormat = any
|
|
|
 |
fdg
|
| Posted: 03/31/2005, 4:11 AM |
|
dfg
|
|
|
 |
datadoit.com
|
| Posted: 03/31/2005, 5:53 AM |
|
<LastHero@forum.codecharge (Last Hero)> wrote in message
news:5424baac10cc3b@news.codecharge.com...
> Right ways:
>
> a)$form->datefield->SetText("2005-03-30") , when Controls Format =
> yyyy-mm-dd
> b)$form->datefield->SetValue(CCParseDate("2005-03-30"), array("yyyy",
> "-",
> "mm", "-", "dd")), ColntrolsFormat = any
> ---------------------------------------
Option a displays the date exactly as it appears in the database, as
expected ("2005-03-30").
Option b displays that infamous 12/31/69.
|
|
|
 |
Last Hero
|
| Posted: 04/01/2005, 4:51 AM |
|
Sorry, mistake.
b)$form->datefield->SetValue(CCParseDate("2005-03-30", array("yyyy", "-", "mm", "-", "dd")))
or
b)
$string="2005-03-30";
$strFormat = array("yyyy", "-", "mm", "-", "dd");
$date = CCParseDate($string, $strFormat);
$form->DateField->SetValue($date);
|
|
|
 |
jvr
Posts: 2
|
| Posted: 07/14/2005, 4:21 AM |
|
PHP: to transform MYSQL-Date-Field to german format I use:
$datevari = CCDLookUp("datevari", "table", "content = 'XYZ'", $DBConnection1);
$datevari = CCParseDate($datevari, array("yyyy", "-", "mm", "-", "dd"));
$datevaritext = CCFormatDate($datevari, array("dd", ".", "mm", ".", "yyyy"));
|
 |
 |
|